Tech Support > Microsoft Windows > Development Resources > Internal Winsock2 connect() timeout
Internal Winsock2 connect() timeout
Posted by edoc on November 12th, 2007


Is it possible to set the connect() timeout for a non blocking socket?
I know of the WaitFor* with timeout but that is not an option for me.
Is there some documentation on where exactly (either userland or
kernel) the timeout value exists? Thanks.

Posted by Christian ASTOR on November 13th, 2007


edoc wrote:

You can use select()
http://www.codeguru.com/forum/showthread.php?t=312668

Posted by Charlie Gibbs on November 13th, 2007


In article <1194884767.345250.314750@v23g2000prn.googlegroups .com>,
rdeviant@gmail.com (edoc) writes:

Another option, which I had cause to use recently, is to make the
connect() itself nonblocking. To do so, move your ioctlsocket()
or WSAAsyncSelect() call immediately ahead of your connect() call.
(You can use ioctlsocket() instead of WSAAsyncSelect() if you have
a console application that doesn't have a window handle, or if you
don't care about notifications.)

You'll have to do a select() to see whether your connection has
been set up (use a timeout value of zero to make the select()
itself nonblocking), but then you're free to go off and do other
things while you're waiting for the connection to set up (or fail).

--
/~\ cgibbs@kltpzyxm.invalid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!



Similar Posts