Jump to content
  • Advertisement
Sign in to follow this  
peter_b

Non-blocking connect()?

This topic is 4384 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!