I have a loop which basically calls this every few seconds (after the timeout):
while(true){ if(finished) return; switch(select(FD_SETSIZE,
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. :)