更新时间:2021-09-08 08:32:12
根据手册页:
ECONNREFUSED 没有人在远程地址上侦听.
ECONNREFUSED No-one listening on the remote address.
为了提供一个简单的远程端点来接受您的连接并发送回接收到的数据(回显服务器),您可以尝试这样的操作 netcat ):
In order to provide a simple remote endpoint that accepts your connection and sends back the received data (echo server), you could try something like this python server (or to use netcat):
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("localhost", 1234))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1024)
if not data: break
conn.sendall(data)
conn.close()