Multicast programming -- setsockopt () Option parameter Summary

Source: Internet
Author: User

 

Multicast programming -- Role Summary of setsockopt () Option Parameters

So_rcvtimeo so_sndtimeo
Sets the network transmission and receipt latency. In the send (), Recv () process, sometimes due to network conditions and other reasons, the sending and receiving cannot be performed as expected, but the sending and receiving time limit is set; doubt: if it times out, it cannot be received or cannot be sent, what will happen?

So_rcvbuf so_sndbuf
By default, the system sends and receives 8688 bytes (about 8.5 KB) at a time. In the actual process, the size of data sent and received is large. You can set a socket buffer.

So_broadcast
Set broadcast.

So_linger
When the end of data is sent, you can set a delay if you do not close the socket immediately.

 

Multicast programming is an important struct:

Struct ip_mreq

{

Struct in_addr imr_multiaddr; // the IP address of the multicast group.

Struct in_addr imr_interface; // ip address of a local network device interface. When a host has two NICs, this parameter determines which IP address is used.

};

Ip_add_membership
Add to multicast group.

Setsockopt (S, ipproto_ip, ip_add_membership, & mreq, sizeof (mreq ));

Ip_multicast_if
The role seems to be a bit repetitive with BIND. For unicast, rcv_saddr = saddr, a member with inet_sock (address used for local data sending = Local data receiving)
When used for multicast, saddr is equal to 0 (that is, the local data sending Address is 0). If you do not know which address to use to send data, this task is left to ip_multicast_if
. To receive multicast data, BIND () is not the IP address of the local host, but the IP address of the specified multicast group. That is to say, to receive the data sent by multicast groups, you must provide the local IP information. In this case, ip_multicast_if is used.

Ip_multicast_loop
Send a multicast datagram to the loopback interface to ensure that the process that the local machine needs to receive the data in the group can receive the data.

Ip_multicast_ttl
Originally, TTL was used to control the lifetime of data packets in the network to prevent endless packet transmission due to router configuration errors; the TTL is 1 224.0.0.0-224.0.0.255, which can only be transmitted within the subnetwork of the sending host and will not be forwarded through the router.

More details

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.