[c++winsock2.0]How to abort winsock blocking call?

前端 未结 3 1500
被撕碎了的回忆
被撕碎了的回忆 2020-12-22 10:04

I use Winsock 2 in C++, and wonder how to make my server stop reading from the client connection. The reading thread gets blocked in recv() and I have no idea h

3条回答
  •  太阳男子
    2020-12-22 10:57

    After I read your response, I got an idea. It end up with setsockopt(). I use it to set time out for recv(), If it's timeout, I just check if system still wanna read from this socket or not.

    This way make reading thread spend most of the time waiting for incoming packet in recv().

    Thank you, Voteforpedro

提交回复
热议问题