breaking out from socket select

前端 未结 4 1884
暖寄归人
暖寄归人 2020-12-04 02:00

I have a loop which basically calls this every few seconds (after the timeout):

 while(true){

    if(finished)
       return;

    switch(select(FD_SETSIZE,         


        
4条回答
  •  遥遥无期
    2020-12-04 02:18

    You can use shutdown(Sock, SHUT_RDWR) call from main thread to come out of waiting select call which will also exit your another thread before the timeout so you don't need to wait till timeout expires.

    cheers. :)

提交回复
热议问题