tovis wrote:
I'm C a programmer, looking for Linux UDP
multicast programming
documentation.
Early I'm write some UDP multicast program for WIN32, using API, it is
working on NT4.0 (loop back does not work, you can not switch off own
packets), W2K and WINXP - where I/O completion port is exist.
In WIn32 API you can simply setup an UDP socket, bind on apropriate
interface address and after using IOCTL set ADD_MEMBERSHIP/DROP_MEMBERSHIP
you can "join" to many groups _ at most I have tested is 4 groups like
224.0.0.xxx on the same port number (for example 6000).
In Linux I had managed to use multicast UDP port but, it seem to be that
it could not "join" to many groups, to receive packets, only one and you
should bind on it (for example on 224.0.0.10:6000)!
Is this right? One UDP socket could receive UDP packets only from one
multicast group in Linux?
Sincerelly
tovis
You can subscribe to as many multicast groups as you want. However, if
you want to listen to the same address/port pair from two different
programs, you need to set the SO_REUSEADDR flag before binding the
socket. In C, you can do that as follows:
#include <sys/socket.h>
#include <netinet/in.h>
...
int reuse=1
...
if(setsockopt(master,SOL_SOCKET,SO_REUSEADDR,&reuse,sizeof(int)) < 0 ){
perror("reuse");
return -1;
}
Regards,
Alain