In writing a file to transfer the socket program, the client implementation and service-side disconnect after the automatic connection function, but connected to the server and then restart the server, the client appeared errno 10054 exception. The code for the error is as follows:
client.py:
Socket
IP = ' 192.168.0.124 '
port = 8000
s = socket.socket (socket.af_inet, socket. SOCK_STREAM)
Run ():
True:
try:
s.connect ((IP, port)
# do Something:send, recv
socket.error, E:
"Get connect error as", E
continue
s.close ()
__name__ = = ' __main__ ':
run ()
Solution: Adjust s = socket.socket (socket.af_inet, socket. SOCK_STREAM) statement, a new socket instance is generated for each reconnection.
client.py:
Socket
IP = ' 192.168.0.124 '
port = 8000
run ():
True:
s = socket.socket (socket. Af_inet, Socket. SOCK_STREAM)
try:
s.connect ((IP, port)
# do something:send, recv
Socket.error, E:
"Get connect error as", E
continue
s.close ()
__name__ = = ' __main__ ': Run ()