PDA

View Full Version : Connect()'ing with a non-blocking socket


tk03
05-12-2003, 01:19 PM
I'm trying to connect to a remote server with a nonblocking socket(Set with fcntl()).
Of course connect returns EINPROGRESS but I'm not sure how to get it past what netstat reports as the SYN_SENT state and actually connected(send() returns Resource unavailable).
I'm basically trying to rewrite the networking code of my program from memory with some modifications but it's working as well as I'd hoped. I'm using non-blocking sockets so I can avoid the problems with forking(X11 doesn't like be used by multiple processes).
I've heard that I'm supposed to just wait until select() for connect to finish but I get a quick stream of select reponses(Not sure how the server responded but my get line code that always is called when select is active gives a empty string) and then nothing more unless I try connecting it to a HTTP server(not the target protocol) in which I get continuous select response. Thanks for any help in advance.

RobSeace
05-12-2003, 07:23 PM
This has been covered in-depth here, previously... See
this thread (http://www.developerweb.net/forum/viewtopic.php?t=147) for a good summary... Or, question 6.2 (http://www.developerweb.net/forum/viewtopic.php?t=80) in the
main FAQ...

Loco
05-12-2003, 10:47 PM
I just added the "connect with timeout" to the main FAQ. So please revisit it:

Question 6.11 (http://www.developerweb.net/forum/viewtopic.php?t=503)

I'll continue updating the main FAQ with Frequently Asked Questions. So I suggest everybody to visit it first and then go post the question if they cannot find answers in these places...