IP multicasting allows an application to send a single IP datagram
that a group of hosts in a network can receive.
The hosts that are in the group can reside on a single
subnet or on different subnets that multicast-capable routers connect. Hosts
can join and leave groups at any time. There are no restrictions on the location
or number of members in a host group. For AF_INET, a class D IP address in
the range 224.0.0.1 to 239.255.255.255 identifies a host group. For AF_INET6,
an IPv6 address starting with FF00::/8 identifies the address as a multicast
address. Refer to RFC 3513: "Internet Protocol Version 6 (IPv6) Addressing
Architecture" for more information.
You can currently use IP multicasting with AF_INET and
AF_INET6 address families.
An application program can send or receive multicast datagrams
using the Sockets API and connectionless, SOCK_DGRAM type sockets. Multicasting
is a one-to-many transmission method. Connection-oriented sockets of type
SOCK_STREAM cannot be used for multicasting. When a socket of type SOCK_DGRAM
is created, an application can use the
setsockopt() function
to control the multicast characteristics associated with that socket. The
setsockopt() function
accepts the following IPPROTO_IP level flags:
- IP_ADD_MEMBERSHIP: Joins the multicast group specified
- IP_DROP_MEMBERSHIP: Leaves the multicast group specified
- IP_MULTICAST_IF: Sets the interface over which outgoing multicast datagrams
should be sent
- IP_MULTICAST_TTL: Sets the Time To Live (TTL) in the IP header for outgoing
multicast datagrams
- IP_MULTICAST_LOOP: Specifies whether a copy of an outgoing multicast datagram
should be delivered to the sending host as long as it is a member of the
multicast group
The
setsockopt() function also accepts
the following IPPROTO_IPv6 level flags:
- IPv6_MULTICAST_IF: Sets the interface over which outgoing multicast datagrams
are sent
- IPv6_MULTICAST_HOPS: Sets the hop limit values that are used for subsequent
multicast packets sent by a socket
- IPv6_MULTICAST_LOOP: Specifies whether a copy of an outgoing multicast
datagram should be delivered to the sending host as long as it is a member
of the multicast group
- IPv6_JOIN_GROUP: Joins the multicast group specified
- IPv6_LEAVE_GROUP: Leaves the multicast group specified