Jump to content
  • Advertisement
Sign in to follow this  
Structural

TCP - C/C++ - accept() - exitting application

This topic is 4807 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

I have a bit of a problem with the accept() function when closing my application: it doesn't fall through. In my connection loop I keep waiting for new connections where the accept() blocks untill a new connection comes in. But when closing down I need the accept() to fall through without there being a new connection, so my thread can exit nicely. How do I make the accept() fall through in a nice manner? Is there a way to "kill" it? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
if u set your flags right on select() you can tell when a new connection is pending, and you should only call accept() when this is the case.

Share this post


Link to post
Share on other sites
I should think that if you close the listening socket, a blocking accept() should come back with an error. Try it to see if it works.

Mark

Share this post


Link to post
Share on other sites
Quote:
Original post by markr
I should think that if you close the listening socket, a blocking accept() should come back with an error. Try it to see if it works.

Mark


This is indeed the case under Windows, but under VxWorks (and I believe LynxOS too) this does not work. I could not find any resources on the Berkeley Sockets that specifies this behaviour.

Share this post


Link to post
Share on other sites
The threading behavior of sockets varies by OS (and by WinSock version on Windows -- make sure you use version 2.2 !)

On UNIX-alikes, you probably would want to unblock the thread by sending it a signal.

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!