Logo         Community
The Company
Your Account
Contact Us
Networking With PEAR
Trawl the archives for PHP versions of common networking tools

| The Scenic Route |

You've figured out that the remote host is operational...now how about figuring out how to get to it? Yup, PEAR comes with an interface to the traceroute command as well, and it goes by the name of Net_Traceroute. You can get it from http://pear.php.net/package/Net_Traceroute. Like Net_Ping, this package too uses the system's traceroute command to calculate the number of hops between the current and destination host. Take a look:

// include class

// initialize object
$tr = Net_Traceroute::factory();

// trace route to host
$result = $tr->traceroute("example.com");

As before, the usage procedure is fairly simple - initialize an object of the class, and then call the traceroute() method with the remote host name or IP address as argument to calculate the route to it.

As with Net_Ping, it's possible to access the individual elements of the response, such as the number of hops or the packet TTL, using special class methods. The following revision of the previous script demonstrates:

// include class

// initialize object
$tr = Net_Traceroute::factory();

// trace route to host
$result = $tr->traceroute("example.com");

// print results
echo "Target IP: " . $result->getTargetIp() . "\n";
echo "Number of hops: " . $result->getHops() . "\n";
echo "TTL: " . $result->getTTL() . "\n";
echo "Raw data: " . implode("\n", $result->getRawData());

How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!

previous page more like this  print this article  next page
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback