Windows插座随机接受和接收

Windows socket accepting and receiving at random

本文关键字:Windows 随机 插座      更新时间:2023-10-16

我刚刚完成了我的跨平台套接字包装器。它在Linux上很好地工作,但是在窗口上我会得到一个非常奇怪的行为。

当我启动服务器(在Loopback端口4242上(时,程序开始接受随机来源的连接并从这些连接中接收。

我终端中记录的内容的示例(这持续发生在非常高的速度上(:

New client connected : 0.0.0.0:58030
Forwarding connection to worker in threadpool...
Waiting for client request...
New client connected : 0.0.0.0:58031
Received 4294967295 bytes from client ''
Forwarding connection to worker in threadpool...
Waiting for client request...
New client connected : Waiting for client request...
Received 4294967295 bytes from client ''0.0.0.0:Received 4294967295 bytes from client ''
58032
Waiting for client request...
Waiting for client request...
Received 4294967295 bytes from client ''
Received 4294967295 bytes from client ''Forwarding connection to worker in threadpool...

在这里,我们可以看到3个连接被接受表格0.0.0.0:580300.0.0.0:580310.0.0.0:58032。对于每个连接,Recv返回大量字节读取,但实际的缓冲区为空。

有什么想法导致这种行为使我的研究定向?

4294967295是-1铸件。因此,您可能会得到-1可能表示某些套接字错误,并将其视为无符号数字的字节。