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?
ForceBru
45k10 gold badges72 silver badges104 bronze badges
1 Answer 1
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().
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-py
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().