[Live-devel] A problem with socketJoinGroupSSM(...) in
GroupsockHelper.cpp
Mingcai Shen
archsh at gmail.com
Thu Mar 9 20:18:28 PST 2006
I'm using liveMedia to build a simple Streaming Server,
and I found there's problem with the socketJoinGroupSSM(...) on WIN32
system, that the sourceFilterAddr should set by IP_MULTICAST_IF,
not IP_ADD_MEMBERSHIP.
So I changed it like this:
Boolean socketJoinGroupSSM(UsageEnvironment& env, int socket,
netAddressBits groupAddress,
netAddressBits sourceFilterAddr) {
if (!IsMulticastAddress(groupAddress)) return True; // ignore this case
#if defined(__WIN32__) || defined(_WIN32)
/**Here Add Win32 Operations By SHENMC 20060303*/
struct ip_mreq imr;
imr.imr_multiaddr.s_addr = groupAddress;
imr.imr_interface.s_addr = ReceivingInterfaceAddr;
if (setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(const char*)&imr, sizeof (struct ip_mreq)) < 0) {
if (env.getErrno() != 0) {
// That piece-of-shit toy operating system (Windows) sometimes lies
// about setsockopt() failing!
socketErr(env, "setsockopt(IP_ADD_MEMBERSHIP) error: ");
return False;
}
}
/**In Win32 system, the sourceFilterAddr should set by IP_MULTICAST_IF */
if(setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF,
(char *)&sourceFilterAddr,
sizeof(sourceFilterAddr)) < 0)
{
socketErr(env, "setsockopt(IP_MULTICAST_IF) error: ");
}
return True;
#else /*NOT WIN32*/
struct ip_mreq_source imr;
imr.imr_multiaddr.s_addr = groupAddress;
imr.imr_sourceaddr.s_addr = sourceFilterAddr;
imr.imr_interface.s_addr = ReceivingInterfaceAddr;
if (setsockopt(socket, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP,
(const char*)&imr, sizeof (struct ip_mreq_source)) < 0) {
socketErr(env, "setsockopt(IP_ADD_SOURCE_MEMBERSHIP) error: ");
return False;
}
return True;
#endif
}
And it can work correctly.
--
Aliex Shen, From the world.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.live555.com/pipermail/live-devel/attachments/20060309/dd5973ee/attachment.html
More information about the live-devel
mailing list