Advertisement

Why is connect() to localhost not blocking ?

Started by January 26, 2004 07:05 AM
3 comments, last by uNiQue0815 21 years ago
does anyone know ? after lots of hours searching for the bug that would let my connect()-call not block, i''ve read in a forum, that this behaviour would be normal !? is there any way to make it block for localhost, too ? i''d really like to have my networking-code behave in a "standardized" way, for whichever host i''m connecting to.
hmmm,
I think that connecting to localhost is just so quick that effectively there is no blocking...

This was the first idea that came to my mind maybe I''m wrong.


--::[MadHed]::--
Advertisement
Going along with AP, try connecting to a non existant IP address and see if it blocks.
When it returns, are you checking the result? It should return zero if successfully connecting. If it isn''t, check WSAGetLastError() for the reason.
- onebeer
connecting to a nonexistant IP lets connect() block for a couple of seconds, then return -1 and errno=113(no route to host)
[WSAGetLastError() = errno -> i'm on linux]
connect() to localhost returns 0.


quote:
I think that connecting to localhost is just so quick that effectively there is no blocking...

but shouldn't connect() always wait until the server accept()ed the connection, before it reports the connection to be established ?
(there was no accept() in my tests)


[edited by - uNiQue0815 on January 26, 2004 7:40:24 PM]
hmm...
that''s strange.

No accept() but connect() was successful...

what port are you connecting to? Maybe there is already a service waiting at that port on your local computer that accepts the connection attempt.

Did you check if bind() executed successful for your server port? Maybe it didn''t bind() because that port is already used... (?)

(btw. I have changed my email address in my profile and haven''t changed my password since... So I''m posting as anonzmous)

--::[MadHed]::--

This topic is closed to new replies.

Advertisement