I'm trying to do this in PHP. I need to check if a specified host is "up"
I thought of pinging the specified host (though I'm not sure how I would, since that would require root. --help here?)
I also though of using fsockopen()
to try to connect on a specified port, but that would fail too, if the host wasn't listening for connections on that port.
Additionally, some hosts block ping requests, so how might I get around this? This part isn't a necessity, though, so don't worry about this too much. I realize this one might get tricky.
I typically do a simple cURL for a public page and see if it returns a 200. If you get a 500, 404, or anything besides a 200 response you know something fishy is up.