【发布时间】:2012-12-08 22:03:40
【问题描述】:
我正在制作一个需要从服务器接收连接哈希的程序。当我使用:
connhash = s.recv(1024)
我收到此错误:
[Errno 10054] An existing connection was forcibly closed by the remote host
这是我的错还是服务器的错?
这是导致 s.recv() 的一些代码
stringfmt = u'%(user)s;%(host)s:%(port)d'
string = stringfmt % data
structfmt = '!bh'
encoded = string.encode('utf-16BE')
packetbytes = struct.pack(structfmt, 2, len(encoded))+encoded
s.send(packetbytes)
connhash = s.recv(1024)
我正在使用 Python v 2.7
编辑:这是为 Minecraft 准备的。
【问题讨论】:
-
她的服务器关闭了连接 - 可能是因为您发送了一些它不理解的内容,也可能是因为它无法正常工作......如果没有更多信息,就不可能说是谁的错。跨度>
-
强制对我来说听起来像是一个 RST(与 FIN 相对)......但如果你真的想知道,你可能应该做一个数据包捕获(tcpdump、wireshark 等)。
标签: python sockets client-server