我正在创建的 python 服务器有问题。它可以在我的家用机器上运行,但是当我尝试在另一台机器上运行它时它不起作用。当使用 pyinstaller 编译时,窗口会立即关闭,当作为原始 python 文件运行时(python 2.7.10 安装在我的家用机器和它不工作的机器上),它会抛出错误:
Traceback (most recent call last):
File "fileModifyServer.py", line 136, in <module>
startServer()
File "fileModifyServer.py", line 11, in startServer
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
File "N:\Python27\lib\socket.py", line 191, in __init__
_sock = _realsocket(family, type, proto)
socket.error: [Errno 10022] An invalid argument was supplied
我引用的代码如下:
import socket
def startServer():
global serversocket
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind((socket.gethostname(), 8010))
serversocket.listen(5)
print "Server started"