There is a thread likes this:
{
......
while (1)
{
recv(socket, buffer, sizeof(buffer), 0);
......
}
close(socket
Do not block on recv. Rather implement a block on 'select' and test the input fdset to determine if there is anything to read in the first place.
If there is data to be read, call recv. If not, loop, check 'isrunning' volitile Boolean variable that gets set by the other thread when shutdown has been initiated.