TCP - C/C++ - accept() - exitting application
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!
STOP THE PLANET!! I WANT TO GET OFF!!
Set the socket to nonblocking and handle EAGAIN error codes.
Look at the accept man page :-)
Look at the accept man page :-)
Winterdyne Solutions Ltd is recruiting - this thread for details!
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.
http://www.p2pmud.com
I was unaware select would fall through when a new connection was pending. I'll do some looking up on that subject then.
Thank you.
Thank you.
STOP THE PLANET!! I WANT TO GET OFF!!
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
Mark
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.
STOP THE PLANET!! I WANT TO GET OFF!!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement