c++ - [c++winsock2.0]How to abort winsock blocking call ? -
I use Winsock 2 in C ++, and wonder how to stop reading my server from the client connection To do. The reading thread is blocked in recv ()
and I do not know how to cancel it. One way to do this is to use non-blocking sockets select ()
, but this thread has to wait before the new select ()
check. .
What is the correct way to stop socket reading?
If there are things other than your program working with socket I / O, Should not be blocked.
If you claim your thread should wait, but it is just a reflection of the current design of your program, you should give it a new look so that it can be used for non-blocking sockets Work with some form Every networking problem can be addressed using non-blocking sockets.
Since you are using Winsock, you have here, not just select ()
. Select ()
is a good option, if your application should run on multiple platforms and you are unable to use the best (but mutually incompatible) options available on every modern platform.
Comments
Post a Comment