connect before listen
Hi there,
Got a winsock question:
I''m writing a Client/Server app right now and using
NonBlocking sockets.
I noticed that if my client''s call to connect to my
server is prior to the server''s call to listen,
the clients further calls to the select function
in order to finalize the link will never succeed.
How to work around that problem in a neat way ?
Thanks for any comments on this.
Lorenz
Other than not calling connect before your server is listening? No neat ways around that... Connect should return an error if the server isn''t listening, are you checking for this... if not, you should..
Whether I check properly ? Good question.
Since a few hours I''m not so sure anymore. Well, the call
to connect returns with WSAWOULDBLOCK. Then the rest is up
to the select which always returns zero (timeout). BUT !
This morning I checked the MSDN for select() once more and
found:
Summary: A socket will be identified in a particular set when select returns if:
readfds:
....
writefds:
....
exceptfds:
If processing a connect call (nonblocking), connection attempt failed
I never cared much about the last one since I already had a hard time enough to get the thing running so I never checked that one.
There has be a way since reconnecting must be possible after a server went down for a short periode of time.
Most propably you''re right, that the server must be listening before a socket can connect and that I have to reset the socket after an unsuccessful try and start over with another connect.
Since a few hours I''m not so sure anymore. Well, the call
to connect returns with WSAWOULDBLOCK. Then the rest is up
to the select which always returns zero (timeout). BUT !
This morning I checked the MSDN for select() once more and
found:
Summary: A socket will be identified in a particular set when select returns if:
readfds:
....
writefds:
....
exceptfds:
If processing a connect call (nonblocking), connection attempt failed
I never cared much about the last one since I already had a hard time enough to get the thing running so I never checked that one.
There has be a way since reconnecting must be possible after a server went down for a short periode of time.
Most propably you''re right, that the server must be listening before a socket can connect and that I have to reset the socket after an unsuccessful try and start over with another connect.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement