There is a thread likes this:
{ ...... while (1) { recv(socket, buffer, sizeof(buffer), 0); ...... } close(socket
You can call:-
shutdown(sock, SHUT_RDWR) //on the remote end
Check this out.