如何解决client_socket.listenOSError:[错误22]无效的参数
我正在尝试套接字编程 我收到此错误
File "python/sockpractice/client1.py",line 5,in <module>
client_socket.listen()
OSError: [Errno 22] Invalid argument
*客户代码为
import socket
client_socket=socket.socket()
client_socket.connect(('127.0.0.1',8080))
client_socket.listen()
conn,addr=client_socket.accept()
while True:
conn.recv(1024)
string=input('#> ')
conn.send(string.encode())
服务器代码是
server_socket=socket.socket()
host='127.0.0.1'
port=8080
binder=(host,port)
server_socket.bind(binder)
server_socket.listen()
connection,address=server_socket.accept()
while True:
string=input('#> ')
connection.send(string.encode())
connection.recv(1024)
请帮助我
我该怎么做才能解决这个问题
解决方法
您不需要客户端上的listen
呼叫。通常,只有服务器端会调用listen
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。