You need to set the method before calling the Connect method of the socket settimeout(time) , and then set the settimeout(None) socket into block mode again after the setting is called again.
The following code example:
Sock=Socket.Socket(Socket.af_inet, Socket.sock. (10) sock.< Span class= "PLN" >connect (addresssock< Span class= "pun". settimeout (none) = Sock. ( ' RB ' , 0
Originally, the socket once set timeout, entered the non-blocking work mode, the original send () and recv () and so on is completely different, may only send or receive some data, need to check the return value and retry several times. Even makefile () is not allowed at all, it has been explicitly stated in the documentation of the socket module, but it is seldom noticed if it is not a somersault here.
With this in mind, it is much more complicated to write the correct code to work in the non-blocking mode, especially for text protocols that do not initially determine the length of the data.
Blocking and non-blocking are completely two different ways of using, not adding a socket.settimeout ().
Python Socket Timeout setting