note 101517 modified in function.fsockopen by danbrown
| From: | danbrown@php.net | Date: | Tue, 21 Dec 2010 20:57:23 +0000 |
| Subject: | note 101517 modified in function.fsockopen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175125@lists.php.net to get a copy of this message | ||
fsockopen(); has issues with certain ports, or programs that use certain ports, so its best to use
an alternate method or a longer code than say just:
<?php
$serv1 = @fsockopen("www.example.com", 27910, $errno, $errstr, 0.25);
if ($serv1){
echo '<br>Server 1 Online';
echo '<img src="images/sonline.gif" width="50" height="8"
alt="Server 1 is Online">';
fclose($serv1);
}else{
echo '<br>Server 1 Offline';
echo '<img src="images/soffline.gif" width="50" height="8"
alt="Server 1 is Offline">';
}
?>
This code will always return offline, even if teh server is online, possibly a different protocol?
Or has to be treated differently to work, I noticed some ports work correctly, while others do not,
even when the port is unblocked...
--was--
fsockopen(); has issues with certain ports, or programs that use certain ports, so its best to use
an alternate method or a longer code than say just:
<?php
$serv1 = @fsockopen("www.mysite.com", 27910, $errno, $errstr, 0.25);
if ($serv1){
echo '<br>Server 1 Online';
echo '<img src="images/sonline.gif" width="50" height="8"
alt="Server 1 is Online">';
fclose($serv1);
}else{
echo '<br>Server 1 Offline';
echo '<img src="images/soffline.gif" width="50" height="8"
alt="Server 1 is Offline">';
}
?>
This code will always return offline, even if teh server is online, possibly a different protocol?
Or has to be treated differently to work, I noticed some ports work correctly, while others do not,
even when the port is unblocked...
http://php.net/manual/en/function.fsockopen.php