

The following examples enable a socket to send and receive multicast datagrams. IP_MULTICAST_LOOP: Specifies whether or not a copy of an outgoing multicast datagram is delivered to the sending host as long as it is a member of the multicast group. Multicast datagrams with a TTL of greater than 1 may be delivered to more than one sub-network, if there are one or more multicast routers attached to the first sub-network.

TTL of 0 are not transmitted on any sub-network. IP_MULTICAST_TTL: Sets the Time To Live (TTL) in the IP header for outgoing multicast datagrams. IP_MULTICAST_IF: Sets the interface over which outgoing multicast datagrams are sent.

IP_DROP_MEMBERSHIP: Leaves the multicast group specified. IP_ADD_MEMBERSHIP: Joins the multicast group specified. The setsockopt() function accepts the following IPPROTO_IP level flags: 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. You cannot use connection-oriented sockets of type SOCK_STREAM for multicasting. Each multicast transmission is sent from a single network interface, even if the host has more than one multicasting-capable interface. A class D Internet address in the range 224.0.0.1 to 239.255.255.255 identifies a host group.Īn application program can send or receive multicast datagrams by using the socket() API and connectionless SOCK_DGRAM type sockets. There are no restrictions on the location or number of members in a host group. Hosts may join and leave groups at any time. The hosts that are in the group may reside on a single subnet or may be on different subnets that have been connected by multicast capable routers. IP multicasting provides the capability for an application to send a single IP datagram that a group of hosts in a network can receive. Beware codes that expand more than one line.Įxample: Sending and receiving a multicast datagram The Fedora machine used for the testing having the " No Stack Execute " disabled and the SELinux set to default configuration. Working program examples if any compiled using gcc, tested using the public IPs, run on Linux Fedora 3 with several times update, as normal user. Network Story 1 Network Story 2 Network Story 3 Network Story 4 Network Story 5 Network Story 6 Socket Example 1 Socket Example 2 Socket Example 3 Socket Example 4 Socket Example 5 Socket Example 6 Socket Example 7 Advanced TCP/IP 1 Advanced TCP/IP 2 Advanced TCP/IP 3 Advanced TCP/IP 4 Advanced TCP/IP 5 NETWORK PROGRAMMING LINUX SOCKET PART 13: MULTICAST
