Why is connect() to localhost not blocking ?
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.
January 26, 2004 01:07 PM
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]::--
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]::--
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.
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.
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]
[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]
January 28, 2004 07:28 AM
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]::--
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...
![](smile.gif)
--::[MadHed]::--
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement