PHP5 fsockopen connection error break site, no matter how I capture it
<p>I'm trying to use fsockopen to communicate with a game server, which responds with some basic stats. It works perfectly when the server is online, but if the server is ever offline, the following code causes php to stop displaying the page that reads the data.</p>

<pre><code>try {
        $socket = fsockopen($host, $port, $errno, $errstr, 10);
        if ($socket !== false) {
                fwrite($socket, "\xFE");
                $data = "";
                $data = fread($socket, 1024);
                fclose($socket);
                if ($data !== false &amp;&amp; substr($data, 0, 1) == "\xFF") {
                       // get into
                } else {
                        // Server did not send back proper data, or reading from socket failed.
                        print "Server not available.";
                }
        } else {
             // ...
        }
} catch(Exception $e){
        // ...
}
</code></pre>

<p>I've tried the try/catch, I've tried adding a custom handler to the exception. My only idea is to run this outside of the web requests and store the response so that the web request isn't initiating it.</p>

<p>Any thoughts?</p>
