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: