connect() timeout?
Any way to set the timeout for connect()? Sometimes it''s 1 second and sometimes it''s indefinite (20+ seconds), depending if the host exists or not (I think). I''d like to make it a consistent timeout...
Of course, I could easily emulate the timeout in my network code, but the problem is, what if the host exists but is slow in accepting the connection. I could have made it time out, but the host has no way of knowing that, so it accept()''s the connection anyway even though the client has stopped bothering with it. Unless there''s a way to inform a host to drop connect request?
One solution is a timer. I recommend creating a timer close the socket altogether.
Kuphryn
Kuphryn
Close what socket? Until connect() returns soemthing meaningful, there isn''t anything to close...
By asynchronous you mean non-blocking, right? That is what I am currently using. But, if you mean asynchronous as in tying your code into the win32 message queue, then that is not an option for me.
There''s got to be a way... it seems a simple enough thing to do!
There''s got to be a way... it seems a simple enough thing to do!
Use non-blocking.
and connect function wont block.
so u will control if ur socket is connected by checking if it is ready to write. with select function.
check select function out on MSDN.
denizpiri@hotmail.com
ICQ#: 120626135
msn: denizpiri@hotmail.com
and connect function wont block.
so u will control if ur socket is connected by checking if it is ready to write. with select function.
check select function out on MSDN.
denizpiri@hotmail.com
ICQ#: 120626135
msn: denizpiri@hotmail.com
I am having the same problem. The connect() function is too slow, and I want to set the timeout of this function. But I dont know how to set the timeout, and you said that you can emulate the timeout... how did you do this?
What I meant was that it''s easy to keep track of when YOU made the connect attempt, and equally easy to know if it''s timed out, since you just look at the delta. But, the problem was (and still is, since I have not really touched my network code lately) that how do you tell WINSOCK to stop the connect procedure?
Looking back on it, I would simply close and recreate the entire socket, which hopefully would stop the connect procedure dead in its tracks
Looking back on it, I would simply close and recreate the entire socket, which hopefully would stop the connect procedure dead in its tracks
![](smile.gif)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement