Go Ip_add_membership: How to resolve multicast errors:

Source: Internet
Author: User

Go Ip_add_membership: How to resolve multicast errors:

Http://www.cnitblog.com/dvb-dvb/archive/2012/10/15/aa.html

By default Live library includes winsock.h through windows.h instead of winsock2.h, but requires Winsock 2 in Initializew Insockifnecessary (...) function.
Ip_add_membership value for Winsock1 are 5, and for Winsock 2 is 12.
Therefore socketjoingroup (...) function is trying to call setsockopt (Ip_add_membership) from Winsock 2 with optname from W Insock 1.
There is the confusion between Winsock versions.


The live555 multicast code is as follows:

TESTADDR.S_ADDR = our_inet_addr ("228.67.43.91"); Arbitrary
Port Testport (15947); Ditto

Sock = Setupdatagramsocket (env, testport);
if (Sock < 0) break;

if (!socketjoingroup (env, sock, TESTADDR.S_ADDR))
{
env<< "Failed to socket Join group\n";
Break
}


Results:

if (setsockopt (socket, ipproto_ip, ip_add_membership,
(const char*) &IMR, sizeof (struct ip_mreq)) < 0) {

Has failed: The error is: 10042:

Modified to: if (setsockopt socket, IPPROTO_IP, 12,
(const char*) &IMR, sizeof (struct ip_mreq)) < 0) {


Because of different socket versions, the value of the definition ip_add_membership is different:

In socket ver1.0:
# define Ip_add_membership 5

In socket ver2.0:
# define Ip_add_membership 12

Go Ip_add_membership: How to resolve multicast errors:

Related Article

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.