HP-UX Reference (11i v2 07/12) - 7 Device (Special) Files, 9 General Information, Index (vol 10)

i
IP(7P) IP(7P)
IP_DROP_MEMBERSHIP
allows the system to leave a multicast group. For example:
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = net_addr("224.1.2.3");
mreq.imr_interface.s_addr = INADDR_ANY;
setsockopt(s, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
The system remains a member of the multicast group until the last socket that joined the group is closed or
has dropped membership in the group.
IP_MULTICAST_IF
specifies a local network interface to be used when sending multicast datagrams
through this socket. For example:
#include <arpa/inet.h>
struct in_addr addr;
addr.s_addr = inet_addr("192.1.2.3");
setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &addr, sizeof(addr));
Normally, applications do not need to specify the interface. By default, multicast datagrams are sent from
the interface specified by the routing configuration, namely the interface associated with the specific multi-
cast group, with the default multicast route or with the default route. If addr is set to the address
INADDR_ANY , the default interface is selected. Otherwise, addr should be the IP address of a local inter-
face.
IP_MULTICAST_LOOP
enables or disables loopback for multicast datagrams sent through this socket.
For example:
unsigned char loop = 1;
setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop));
Note that the type of the optval parameter is unsigned char instead of int, which is common for
boolean socket options. This option is provided for compatibility only. Normally, if a multicast datagram is
sent to a group that the system has joined, a copy of the datagram is always looped back and delivered to
any applications that are bound to the destination port. See DEPENDENCIES below.
IP_MULTICAST_TTL
controls the scope a multicast by setting the time-to-live value for multicast
datagrams sent through this socket. For example:
unsigned char ttl = 64;
setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
Note that the type of optval parameter is unsigned char instead int, which is common for socket
options. By default, the time-to-live field (TTL) is one, which limits the multicast to the local network. If
the TTL is zero, the multicast is limited to the local system (loopback). If the TTL is two, the multicast can
be forwarded through at most one gateway; and so forth. Multicast datagrams can be forwarded to other
networks only if there are special multicast routers on the local and intermediate networks.
DEPENDENCIES
The behavior of IP_MULTICAST_LOOP
depends on the network driver and interface card. Normally,
loopback cannot be disabled, even if
IP_MULTICAST_LOOP
is set to zero, because it occurs in the driver
or in the network interface. However, if the outbound interface is
lo0 (127.0.0.1), or if
IP_MULTICAST_TTL is set to zero, setting IP_MULTICAST_LOOP
to zero will disable loopback for
multicast datagrams sent through the socket.
ERRORS
One of the following errors may be returned if a call to
setsockopt() or getsockopt() fails.
[EADDRINUSE] The specified multicast group has been joined already on socket.
[EADDRNOTAVAIL] The specified IP address is not a local interface address; or there is no route
for the specified multicast address; or the specified multicast group has not
been joined.
[EINVAL] The parameter level is not IPPROTO_IP ;oroptval is the NULL address; or
the specified multicast address is not valid.
[ENOBUFS] Insufficient memory is available for internal system data structures.
[ENOPROTOOPT] The parameter optname is not a valid socket option for the IPPROTO_IP
level.
66 Hewlett-Packard Company 2 HP-UX 11i Version 2: December 2007 Update