This says, foreach of the $key => $value pairs on $write_map array, which is an array of sockets and is dynamic, write $data['buf'] as if $data['fr'] is equal to this socket. As long as fwrite writes data (not false), buffer more data to the $data['buf'] which is the remaining data between $data['buf'] and the length written. Once empty, we close the stream.
This process will occur as long as $write_map has one or more items in it. As soon as you close the socket you can no longer write to it, which will cause an error. Removing it from the $write_map will prevent it from trying this again.
I cannot be 100% certain if this works to tell you the truth. Without being able to test this, I can only speculate on what appears to be the case. However, I also assume that the /* ???? */ is to indicate only 1 line of instructions is necessary, and the unset appears to be the proper one.
Can anyone please confirm?
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php