🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
how do you get out of a blocking recv() call?
the recv is in a seperate thread btw, there has to be a better way of doing it, other then terminating the thread.
The Right Thing to do is to not let it block in the first place by making sure that you have data to read. To do that, you would use select(), which will block until something happens on the sockets (Note: plural) it is watching. And if you want to make it bail out on demand (and not with a timeout), you plug in another ''control'' socket, which will cause a shutdown when data is received on it.
For more details on the use of select, search the discussions, that question has come up before.
For more details on the use of select, search the discussions, that question has come up before.
TerminateThread is evil, don''t even think of using it.
Your two options are to use select with a timeout like Fruny suggested or to close the socket that the the thread is waiting on. And I''m not sure if the second method is portable and/or safe.
-Mike
Your two options are to use select with a timeout like Fruny suggested or to close the socket that the the thread is waiting on. And I''m not sure if the second method is portable and/or safe.
-Mike
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement