简体   繁体   English

IPPROTO_RM在接受呼叫期间阻止

[英]IPPROTO_RM blocks during accept call

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. 这个问题类似于https://stackoverflow.com/questions/11650328/using-reliable-multicast-pragmatic-general-multicast-not-returning-from-accept ,但我的代码与它略有不同,因此可能会导致在一个不同的答案。

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. 客户端通过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 . 客户端通过TCP发送消息,服务器通过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). 我已经设置了类似的RM套接字(参见下面的清单)。 The TCP sockets are working fine. TCP套接字工作正常。 The problem is in the RM sockets. 问题在于RM套接字。 The server opens up the multicast socket, then binds and connects to the multicast address properly. 服务器打开多播套接字,然后正确bindsconnects到多播地址。 The client, however, listens correctly, but the call to accept blocks forever. 但是,客户端正确地listens ,但是永远accept阻止的呼叫。

Both client and server processes are running on the same host. 客户端和服务器进程都在同一主机上运行。

I have checked, and Multicasting support is installed on the host (Server 2008). 我已经检查过,主机上安装了多播支持(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. 我们发生了一个搞笑的事件,导致整栋大楼失去了通讯。


Listings 房源

Server creates and connects Multicast sender 服务器创建并连接多播发送方

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;

Client creates and accepts Multicast reader 客户端创建并接受多播读取器

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 ? 你安装了MSMQ(微软消息队列)吗? it is required for IPPROTO_RM to work on Ms based computers. IPPROTO_RM需要在基于Ms的计算机上工作。 Plus it will only work for Windows version >= Xp||2003 此外,它仅适用于Windows版本> = Xp || 2003

Edit:I saw that you already checked it. 编辑:我看到你已经检查过了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM