我正在尝试从树莓派连接到套接字。在正常的Python IDLE中,它工作正常,我能够接收数据。当我从树莓派运行代码时,会出现此错误。我在SO中尝试了所有可能的答案,但没有任何效果。这是我的代码供参考。
代码:
import socket, csv,time,struct
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip = '127.0.x.x'
port = 50xxx
address = (ip,port)
i=0
client.connect(address)
print("connected")
while 1:
client.send(b'\x01\x04\x00\x00\x00\x4E\x70\x3E')
print("sent")
T_data = client.recv(1024)
print(T_data)
输出:
connected
sent
错误:
Traceback (most recent call last):
File "exdu.py", line 11, in <module>
T_data = client.recv(1024)
socket.error: [Errno 104] Connection reset by peer