actordc
actordc

Reputation: 1

Python Socket Timeout

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?

Upvotes: 0

Views: 263

Answers (1)

Armali
Armali

Reputation: 19375

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().

Upvotes: 1

Related Questions