Using the same port for 2 UDP Multicast groups
I habe a program, that can send and receive UDP Multicast telegrams. When I open the socket then I bind my multicast group address and the local port to a specified networkcard (our PC has 2 network cards). Now I have a special constellation:
Our PC has 2 network cards. Multicast group 1 shall use card 1 and group shall use card 2. As long as both groups use different local ports it works fine. But when both group want to use the same port number then I can receive and send telegrams only through the first group that was created. For the second one I don't even get a FD_READ event at all.
Code:
SrvAddr.sin_family = AF_INET;
SrvAddr.sin_port = htons( (WORD) nLocalPort );
SrvAddr.sin_addr.s_addr = inet_addr(strOwnIpAddress); // bind multicast group socket to a specified networkcard
// If bind socket to port failed
if( bind( hSocket,
(const struct sockaddr *) &SrvAddr,
sizeof(SrvAddr) ) == SOCKET_ERROR )
{
WSACloseEvent(ptChannel->Overlapped.hEvent);
closesocket(hSocket);
WSACleanup();
return ceUdpErrBind;
} // END OF If bind socket to port failed
Re: Using the same port for 2 UDP Multicast groups
I found my mistake. Problem is solved
Re: Using the same port for 2 UDP Multicast groups
Quote:
Originally Posted by
grka
I found my mistake. Problem is solved
Will you be so kind to share your solution?