Yeah, I do read, and you are using ping before fsockopen. There's no reason to use ping if you're not using the response time.
And your script does work, I just tested it with my web server, port 80, and it said it was online.
What I mean but not needing to use ping, is like this:
function ping($host, $port) {
$ip=gethostbyname($host);
if (!fsockopen($ip, $port, &$errno, &$errstr, 30)) {
echo "<p>error num: ".$errno."</p>".$errstr;
} else {
echo "Online";
}
}
That's enough to tell whether a port is open or not. You don't need to first test if the computer is online or not.
Diego