我正在创建一个使用套接字进行通信的简单服务器(C#)和客户机(python)。在
服务器创建一个
var listener = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp)
然后绑定,在无限循环中监听
^{pr2}$AcceptCallback
调用BeginReceive,其callbackk读取缓冲区并向客户端发回消息
一切正常。客户机发送消息,服务器看到,回复,客户机看到。但当客户机再次尝试发送消息时(因为测试客户机处于循环中),什么都不会发生
python客户端:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, port))
while True:
sock.sendall(data)
blockLen = sock.recv(32) #server sends back a string prefixed with how long the string is
serverReply = sock.recv(blockLen)
我如何防止插座死掉?在
来自MSDN(Remarks on EndAccept):
还有一个关于stackoverflow check的问题,有帮助吗?在
相关问题 更多 >
编程相关推荐