title: Unable to connect with fsockopen in PHP (Connection timed out)
body: <p>I developed an application for a friend and he recently changed his dedicated server for overload problems.</p>
  <p>Since this migration, a part of the site doesn't work anymore: a connection on a socket in PHP.</p>
  <p>In this part, I had to establish a connection with another server so I realized a function to open a socket:</p>
  <pre><code>function openSocket($host, $port) {
      $fp = fsockopen($host, $port, $errno, $errstr, 30);
      
      if (!$fp) {
          return 0;
      }
      
      fputs($fp, $envoi);
      
      return $fp;
  }
  </code></pre>
  <p>In the code, I use this function like that:</p>
  <pre><code>$sock = openSocket($host, $port);
  
  while (!feof($sock)) {
      echo fread($sock, 8192);
  }
  
  fclose($sock);
  </code></pre>
  <p>Sometimes, I need to open the socket for several minutes and since the migration, my friend has this error in his log:</p>
  <blockquote>
  <p>PHP Warning: fsockopen(): unable to connect to ...:80 (Connection
  timed out) in ..., referer: ...</p>
  </blockquote>
  <p>I searched if there was a specific configuration in PHP / Apache but I found nothing.</p>
  <p>I tried to increase the last parameters of fsockopen or the stream_set_timeout() function but nothing worked.</p>
  <p>Thank you for your help</p>