note 72674 added to function.fsockopen
| From: | ryan1_00 at hotmail dot com | Date: | Mon, 29 Jan 2007 15:52:10 +0000 |
| Subject: | note 72674 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122319@lists.php.net to get a copy of this message | ||
Sorry for multiple submission of this but Added @ to suppress errors and a few exmples:
Also note that this script checks specific ports so you need to have the correct port open on the
server for this to work.
E.g if i have a windows domain controller and it is servering LDAP then the following would be used
to check it is online:
chkServer("MyDC", "389");
for a webserver
chkServer("MyWebSvr", "80");
etc etc
--------------------------------------------------------
// 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/72674
Del: integrated -- https://master.php.net/note/delete/72674/integrated
Del: useless -- https://master.php.net/note/delete/72674/useless
Del: bad code -- https://master.php.net/note/delete/72674/bad+code
Del: spam -- https://master.php.net/note/delete/72674/spam
Del: non-english -- https://master.php.net/note/delete/72674/non-english
Del: in docs -- https://master.php.net/note/delete/72674/in+docs
Del: other reasons-- https://master.php.net/note/delete/72674
Reject -- https://master.php.net/note/reject/72674
Search -- https://master.php.net/manage/user-notes.php