Just a note to say that if you encounter problem closing some sockets using fclose in a multi client server, you should really give this one a try.
Spent a full day trying to resolve this issue using stream_socket_shutdown($clientStream,STREAM_SHUT_RDWR);
finally do the trick.