title: Php socket_close() hang my client untill the server disconect me
body: <p>This is my php client code:</p>
  
  <pre><code>&lt;?php
      $service_port = 5310;
      $address = gethostbyname('192.168.40.100');
  
      $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
      if ($socket === false)
          echo "socket_create() falló: razón: " . socket_strerror(socket_last_error()) . "&lt;br /&gt;";
      else
      {
          $result = socket_connect($socket, $address, $service_port);
          if ($result === false)
              echo "socket_connect() falló.\nRazón: ($result) " . socket_strerror(socket_last_error($socket)) . "&lt;br /&gt;";
          else
          {   
              $in = "Envio esto: HOLA";
              $out = 'RESPONSE: ';
              echo "ANTES: " . date("H:i:s") . "&lt;br /&gt;"; // #1
              socket_write($socket, $in, strlen($in));
              echo "DESPUÉS: " . date("H:i:s") . "&lt;br /&gt;"; // #2 Same time as #1
              // Leer/imprimir respuesta
              while ($out = socket_read($socket, 2048))
                  echo "RESPONSE: " . date("H:i:s") . " " . $out; // #3 Same time as #2
          }
      }
  
      // Cerramos socket
      socket_close($socket);
      echo "BANANA: " . date("H:i:s") . "&lt;br /&gt;"; // Always run when I got disconected from server
  ?&gt;
  </code></pre>
  
  <p>I don't have access to the <code>server code</code>, but I read a little bit, it's writen in <code>VB.net</code> and it uses something like <code>Client.socket.send()</code>, I got the response and I see those echo well printed when the server disconect me, if not, my php will be hanged out in the nowhere.</p>
  
  <p><strong>EDIT</strong>
  I added another <code>socket_write()</code> in order to tell the server that, please, disconect me, but the second one is not being sent to the server.</p>
  
  <pre><code>&lt;?php
      $service_port = 5310;
      $address = gethostbyname('192.168.40.100');
  
      $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
      if ($socket === false)
          echo "socket_create() falló: razón: " . socket_strerror(socket_last_error()) . "&lt;br /&gt;";
      else
      {
          $result = socket_connect($socket, $address, $service_port);
          if ($result === false)
              echo "socket_connect() falló.\nRazón: (" . $result . ") " . socket_strerror(socket_last_error($socket)) . "&lt;br /&gt;";
          else
          {   
              $in = "Envio esto: HOLA";
              $out = '';
              $response = "RESPONSE: ";
              echo "PRIMERA;";
              socket_write($socket, $in, strlen($in));
              while ($out = socket_read($socket, 2048))
                  $response .= $out;
              echo $response . ";SEGUNDA;";
              $in = "close";
              $out = '';
              $response = "";
              socket_write($socket, $in, strlen($in));
              while ($out = socket_read($socket, 2048))
                  $response .= $out;
              echo $response . " " . date("H:i:s");
          }
      }
      socket_close($socket);
  ?&gt;
  </code></pre>