How to cleanly interrupt a thread blocking on a recv call?

前端 未结 3 912
我在风中等你
我在风中等你 2021-01-02 06:51

I have a multithreaded server written in C, with each client thread looking something like this:

ssize_t n;
struct request request;

// Main loop: receive re         


        
3条回答
  •  不知归路
    2021-01-02 07:11

    Shutdown the socket for input from another thread. That will cause the reading thread to receive an EOS, which should cause it to close the socket and terminate if it is correctly written.

提交回复
热议问题