How to let a thread which blocks on recv() exit gracefully?

后端 未结 7 1810
暗喜
暗喜 2020-12-11 17:27

There is a thread likes this:

{  
    ......    
    while (1)
    {
        recv(socket, buffer, sizeof(buffer), 0);
        ......
    }
    close(socket         


        
相关标签:
7条回答
  • 2020-12-11 18:08

    You can call:-

    shutdown(sock, SHUT_RDWR)    //on the remote end
    

    Check this out.

    0 讨论(0)
提交回复
热议问题