代替
host = socket.gethostname() #Get the local machine nameport = 12397 # Reserve a port for your services.bind((host,port)) #Bind to the port
你应该试试
port = 12397 # Reserve a port for your services.bind(('', port)) #Bind to the port这样监听套接字就不会太受限制。否则,侦听可能只发生在一个接口上,而该接口又与本地网络无关。
一个示例可能是它仅侦听
127.0.0.1,这使得不可能从其他主机进行连接。



