1

I've noticed that sometimes select returns with Connection Timed out set on errno, but I dont know why it would do this, how would it know? And how are you suppose to deal with this? (Im guessing it means that one of the connections timed out, perhaps an ACK wasnt heard back from at an appropriate time). Id imagine the only legit case of this would be if a server socket is in there and you ran a nonblocking connect before? In which case running a connect on this socket again would return to you whether it was connected or not, and that would be the way to handle that.... but is there a better way?

Thanks in advance.

Cenoc
  • 11,172
  • 21
  • 58
  • 92
  • Yes, this should only happen with nonblocking `connect`, but I forget the right way to use nonblocking `connect` with `select` so I'm writing this as a comment rather than an answer. – R.. GitHub STOP HELPING ICE Dec 05 '10 at 02:24

1 Answers1

0

As the commenter above said, this is probably the result of a select() on a non-blocking connect(). Unless this is a timeout in general, in which case it can happen for incoming accepted TCP sockets as well sometimes. Either way, below are two very useful guides to refresh your memory on the usage of select():

http://www.lowtek.com/sockets/select.html

http://beej.us/guide/bgnet/output/html/multipage/advanced.html#select

http://beej.us/guide/bgnet/output/html/multipage/advanced.html#blocking

See also this question for a Python example:

How can I get non-blocking socket connect()'s?

Cheers.

Community
  • 1
  • 1
ido
  • 844
  • 6
  • 6