0

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?

3
  • settimeout Commented Sep 10, 2015 at 19:09
  • 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(). Commented Sep 10, 2015 at 19:10
  • You also might want to look into non blocking sockets, I had a great deal of joy with them (: Commented Sep 10, 2015 at 19:33

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.