note 72673 added to function.fsockopen
| From: | ryan1_00 at hotmail dot com | Date: | Mon, 29 Jan 2007 15:44:55 +0000 |
| Subject: | note 72673 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122318@lists.php.net to get a copy of this message | ||
Function to "ping" a server.
// check if a server is up by connecting to a port
function chkServer($host, $port)
{
$hostip = gethostbyname($host); // resloves IP from Hostname returns hostname on failure
if ($hostip == $host) // if the IP is not resloved
{
echo "Server is down or does not exist";
}
else
{
if (!$x = fsockopen($hostip, $port, $errno, $errstr, 5)) // attempt to connect
{
echo "Server is down";
}
else
{
echo "Server is up";
if ($x)
{
fclose($x); //close connection (i dont know if this is needed or not).
}
}
}
}
----
Server IP: 83.138.144.80
Probable Submitter: 212.44.43.189
----
Manual Page -- http://www.php.net/manual/en/function.fsockopen.php
Edit -- https://master.php.net/note/edit/72673
Del: integrated -- https://master.php.net/note/delete/72673/integrated
Del: useless -- https://master.php.net/note/delete/72673/useless
Del: bad code -- https://master.php.net/note/delete/72673/bad+code
Del: spam -- https://master.php.net/note/delete/72673/spam
Del: non-english -- https://master.php.net/note/delete/72673/non-english
Del: in docs -- https://master.php.net/note/delete/72673/in+docs
Del: other reasons-- https://master.php.net/note/delete/72673
Reject -- https://master.php.net/note/reject/72673
Search -- https://master.php.net/manage/user-notes.php