Sign in to follow this  

Non-blocking connect()?

This topic is 4101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. Is there anything i can do to know when a non-blocking connect finishes? I need to know when the connection is accepted or if it times out. Im using berkely socket functions only, not winsock asyncronus functions. So i guess there must be a way to poll the socket with select() or something. But how do i know if the connection was accepted, timedout, or rejected? Thanks in advance.

Share this post


Link to post
Share on other sites
It's also possible to use non-blocking sockets. Just keep calling connect() and handle the errors appropriately:
The first call will probably return WOULDBLOCK or INPROGRESS which is fine, after that you will get INVAL or ALREADY which can be ignored. When the connection succeeds you will get ISCONN, then you can stop calling connect() and start using the socket.


Share this post


Link to post
Share on other sites

This topic is 4101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this