phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP Network: Pinging Remote Hosts

Tag: network, ping, remote host   Category: PHP Basic
post: 28 Apr 2008 read: 313


PHP Network Tips - Part 1: If we want to check if a network host is alive, we use ping system command. Example, if we want to check phpeveryday.com is alive we can use ping phpeveryday.com (for Windows). We can use ping at PHP. The code like this:

<?php
exec("ping localhost", $output);
echo "<pre>".join("\r\n", $output)."</pre>";
?>

Ping command depend on Operating System. I use Win XP. And I just check localhost. You can try other network host by replace localhost above. Result may like this:


Pinging DIGI01 [127.0.0.1] with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
PHP WDDX: Recordset Element
Joomla: Fast Road to Understand Component Programming
Web Services: How PHP Kiss VB.NET? (Part 1)
mod_rewrite - Part 1: create your "fantasy" URL
PHP Supported Metacharacters (You Must Know Them)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


624
posting