Eiolon Posted February 6, 2010 Share Posted February 6, 2010 I am working on a server status script using fsockopen. When the server is online, it displays online fine. However, when it is offline, it lists the server offline but gives me an fosckopen error. How do I make it so the PHP error is not shown and just the offline is shown? <?php function server_check ($hport,$hdomain) { $fp = fsockopen($hdomain, $hport, $errno, $errstr, 4); if (!$fp){ $data = "<font color=red>OFFLINE</font>"; } else { $data = "<font color=green>ONLINE</font>"; fclose($fp); } return $data; } ?> <?php echo "<table width=200 border=0 cellspacing=1 cellpadding=6 bgcolor=#CCCCCC>"; echo "<tr bgcolor=#E5E5E5><td width=100><strong>Service</strong></td>"; echo "<td width=100><div align=center><strong>Status</strong></div></td></tr>"; echo "<tr bgcolor=#FFFFFF><td width=100>Polaris</td>"; echo "<td width=100><div align=center>".server_check("3389","192.168.19.42")."</div></td></tr>"; echo "<tr bgcolor=#FFFFFF><td width=100>SIP</td>"; echo "<td width=100><div align=center>".server_check("5000","192.168.19.31")."</div></td></tr></table>"; ?> Here is the error that is being shown: Warning: fsockopen() [function.fsockopen]: unable to connect to 192.168.19.31:5000 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\wamp\www\includes\functions.php on line 16 Quote Link to comment Share on other sites More sharing options...
trq Posted February 7, 2010 Share Posted February 7, 2010 $fp = @fsockopen($hdomain, $hport, $errno, $errstr, 4); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.