I am currently using socket.recv to recieve a message from a server with my client. Is there any way, if no message has been recieved for 5 seconds, to display a custom error and close the connection + client?
1 Answer
Use socket.settimeout() before you perform a blocking operation to control its timeout. So in your case it sounds like you don't want a timeout for connect(), but one for recv().
settimeoutsocket.settimeout()before you perform a blocking operation to control its timeout. So in your case it sounds like you don't want a timeout forconnect(), but one forrecv().