这是我的代码
import socket,time
host = ''
port = 50015
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((host, port))
server.listen(1) # 接收的连接数
client, address = server.accept()
while True: # 循环收发数据包,长连接
data = client.recv(1024)
print(data.decode('utf-8'))
if data==None:
break
time.sleep(0.5)
服务器运行报错信息为:
Traceback (most recent call last):
File "server.py", line 15, in <module>
data = client.recv(1028)
ConnectionResetError: [Errno 104] Connection reset by peer