HP-UX Reference (11i v2 03/08) - 5 Miscellaneous Topics, 7 Device (Special) Files, 9 General Information, Index (vol 9)

i
IP(7P) IP(7P)
NAME
IP - Internet Protocol
SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
s = socket(AF_INET, SOCK_DGRAM, 0);
DESCRIPTION
IP is the network-layer protocol used by the Internet protocol family. It encapsulates TCP and UDP mes-
sages into datagrams to be transmitted by the network interface. Normally, applications do not need to
interface directly to IP. However, certain multicast socket options are controlled by passing options to the
IPPROTO_IP protocol level through a UDP socket, and IP Type of Service is controlled by passing an
option to the IPPROTO_IP protocol level through either a TCP or UDP socket. (See the getsockopt (2)
manual page.)
The following socket options are defined in the include file
<netinet/in.h>
. The type of the variable
pointed to by the optval parameter is indicated in parentheses. The data types
struct ip_mreq and
struct in_addr are defined in
<netinet/in.h>.
IP_TOS (unsigned int) Sets the IP Type of Service. Allowable values for
optval are 4 for high reliability, 8 for high throughput, and 16 for low
delay. Other values will not return an error, but may have unpredict-
able results. Default: zero.
IP_ADD_MEMBERSHIP
(struct ip_mreq) Requests that the system join a multicast group.
IP_DROP_MEMBERSHIP
(struct ip_mreq) Allows the system to leave a multicast group.
IP_MULTICAST_IF (
struct in_addr) Specifies a network interface other than the default
to be used when sending multicast datagrams through this socket.
Default: multicast datagrams are sent from the interface associated with
the specific multicast group, with the default multicast route or with the
default route.
IP_MULTICAST_LOOP
(unsigned char; boolean) Enables or disables loopback in the IP layer
for multicast datagrams sent through this socket. The value of the vari-
able pointed to by optval is zero (disable) or non-zero (enable). This
option is provided for compatibility only. Normally, multicast datagrams
are always looped back if the system has joined the group. See DEPEN-
DENCIES below. Default: enabled.
IP_MULTICAST_TTL (
unsigned char) Specifies the time-to-live value for multicast
datagrams sent through this socket. The value of the variable pointed to
by optval can be zero through 255. Default: one.
IP_ADD_MEMBERSHIP requests that the system join a multicast group on the specified interface. 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_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
A system must join a group on an interface in order to receive multicast datagrams sent on the network to
which that interface connects. If imr_interface is set to INADDR_ANY, the system joins the specified
group on the interface that datagrams for that group would be sent from, based the routing configuration.
Otherwise, imr_interface should be the IP address of a local interface. An application can join up to
IP_MAX_MEMBERSHIPS multicast groups on each socket. IP_MAX_MEMBERSHIPS is defined in
<netinet/in.h>. However, each network interface may impose a smaller system-wide limit because
of interface resource limitations and because the system uses some link-layer multicast addresses.
The application must also bind to the destination port number in order to receive datagrams that are sent
to that port number. If the application binds to the address
INADDR_ANY, it may receive all datagrams
that are sent to the port number. If the application binds to a multicast group address, it may receive
only datagrams sent to that group and port number. It is not necessary to join a multicast group in order
to send datagrams to it.
HP-UX 11i Version 2: August 2003 1 Hewlett-Packard Company Section 749