My client program need to receive UPD traffic from multiple multicast groups. And the problem is: the client need to tell each received packet belongs to which multicast group. Simply recvfrom() is not enough, because I need the destination adress as well as the source address.
It is easy with FreeBSD system: create a single socket, join multiple multicast groups at the same time. Set the socket option IP_RECVDSTADDR, and use recvmsg() can get the destination address.
However, this is not OK with Solaris, which do not support control message header. So I create multiple sockets, each socket will join one group. and select() was used to corrdinate to receive from all these sockets.
However, even this can't work with Windows. Because each socket need to bind() to an address. can't bind to INADDR_ANY, otherwise, a socket can get traffic of all groups. Still can't bind to unicast address, because all the socket listen on the same UDP port. In solaris, I bind to the multicast address. But in Windows, the system do not permit to bind to a multicast address.
Does any one know how to deal with this problem?
Is there any general solution on this?
Thanks in advance
It is easy with FreeBSD system: create a single socket, join multiple multicast groups at the same time. Set the socket option IP_RECVDSTADDR, and use recvmsg() can get the destination address.
However, this is not OK with Solaris, which do not support control message header. So I create multiple sockets, each socket will join one group. and select() was used to corrdinate to receive from all these sockets.
However, even this can't work with Windows. Because each socket need to bind() to an address. can't bind to INADDR_ANY, otherwise, a socket can get traffic of all groups. Still can't bind to unicast address, because all the socket listen on the same UDP port. In solaris, I bind to the multicast address. But in Windows, the system do not permit to bind to a multicast address.
Does any one know how to deal with this problem?
Is there any general solution on this?
Thanks in advance