This question is similar to https://stackoverflow.com/questions/11650328/using-reliable-multicast-pragmatic-general-multicast-not-returning-from-accept, but my code is slightly different from its, so it may result in a different answer.
I am attempting to get a reliable-multicast server/client proof of concept setup.
The solution itself is a server/client connection. The client connects to the server via TCP/IP. The server then opens up a reliable multicast socket for the client to listen on. The client sends messages via TCP, and the server echoes it back via IPPROTO_RM
. The end goal is to have many clients connected to the server, all receiving every echoed message.
The example code is based off of this page.
I have set up my RM sockets similarly (see listings below). The TCP sockets are working fine. The problem is in the RM sockets. The server opens up the multicast socket, then binds
and connects
to the multicast address properly. The client, however, listens
correctly, but the call to accept
blocks forever.
Both client and server processes are running on the same host.
I have checked, and Multicasting support is installed on the host (Server 2008).
Update: I've noticed that sometimes the accept will return if I send some data down the socket from the sender's side first. This is not ideal, nor is it reliable.
Update: The signs are pointing to the switch. Seems like a little hub won't cut it. We had an hilarious incident which resulted in lost comms for the whole building.
short
Port = 0;
const char
*Address = "234.5.6.7";
SOCKET
RMSocket;
SOCKADDR_IN
LocalAddr,
SessionAddr;
RMSocket = socket(AF_INET, SOCK_RDM, IPPROTO_RM);
if (RMSocket == INVALID_SOCKET)
{
return Failed;
}
LocalAddr.sin_family = AF_INET;
LocalAddr.sin_port = htons(0);
LocalAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if ( bind( RMSocket, (SOCKADDR*)&LocalAddr, sizeof(LocalAddr)) == SOCKET_ERROR )
{
return Failed;
}
SessionAddr.sin_family = AF_INET;
SessionAddr.sin_port = htons( Port );
SessionAddr.sin_addr.s_addr = inet_addr( Address );
if ( connect( RMSocket, (SOCKADDR*)&SessionAddr, sizeof(SessionAddr)) == SOCKET_ERROR )
{
return Failed;
}
return Success;
short
Port = 0;
const char
*Address = "234.5.6.7";
SOCKADDR_IN
LocalAddr;
SOCKET
RMListener,
RMSocket;
RMListener = socket( AF_INET, SOCK_RDM, IPPROTO_RM );
if ( RMListener == INVALID_SOCKET )
{
return Failed;
}
LocalAddr.sin_family = AF_INET;
LocalAddr.sin_port = htons( Port );
LocalAddr.sin_addr.s_addr = inet_addr( Address );
if ( bind( RMListener, (SOCKADDR*)&LocalAddr, sizeof(LocalAddr) ) )
{
return Failed;
}
if ( listen( RMListener, SOMAXCONN ) )
{
return Failed;
}
// BLOCKS HERE
RMSocket = accept( RMListener, NULL, NULL);
if ( RMSocket == INVALID_SOCKET )
{
return Failed;
}
return Success;
Do you have MSMQ (microsoft message queuing) installed ? it is required for IPPROTO_RM to work on Ms based computers. Plus it will only work for Windows version >= Xp||2003
Edit:I saw that you already checked it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With