View Single Post
Old 11-28-2005, 07:47 PM   #3
Leigh
Junior Member
 
Join Date: Nov 2005
Location: Ontario, Canada
Posts: 10
Default

Well, after much digging around I discovered the fsockopen function on PHP.NET and cobbled together this little snippet of code:

PHP Code:
$isThere = @ fsockopen("10.0.0.25"135$errno$errstr10);
if (!
$isThere) {
 echo 
"Offline";
} else {
 echo 
"Online";

It's not a true PING as PING doesn't really use a port, but fsockopen requires a port to be specified. I used the infamous TCP port 135. The other parameters aren't required for this little snippet, but I left them there for completeness.

The other problem I had with this snippet was that if a PC is offline, I got a couple of PHP warnings that broke the display. Once again, Google to the rescue, I found that putting the "@" sign in front of the function suppressed the warnings. That was new one to me!
Leigh is offline   Reply With Quote