PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Net_Ping checkHost didn't work..

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Networking
View previous topic :: View next topic  
Author Message
isurkov



Joined: 04 Feb 2007
Posts: 3

PostPosted: Sun Feb 04, 2007 2:09 pm    Post subject: Net_Ping checkHost didn't work.. Reply with quote

Please give me some example of using the checkHost function in Net_Ping package , to check some host. I tried many ways, but many errors occurs. Sad
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Feb 04, 2007 5:21 pm    Post subject: Re: Net_Ping checkHost didn't work.. Reply with quote

isurkov wrote:
Please give me some example of using the checkHost function in Net_Ping package , to check some host. I tried many ways, but many errors occurs. Sad


I don't have an example and also haven't used that package. But if you show us your code and tell us what error messages you get, we might be able to help you anyway.
Back to top
View user's profile Send private message
isurkov



Joined: 04 Feb 2007
Posts: 3

PostPosted: Sun Feb 04, 2007 8:08 pm    Post subject: Reply with quote

Code is:

Code:

<?php
set_include_path('c:/Servers/php5/pear');
require 'Net/Ping.php';
$ping = new Net_ping;
if($ping->checkHost('www.yahoo.com'))
{print 'Reachable';}
else
{print 'Unreachable';}

$data = $ping->ping('www.yahoo.com');
?>



and i get an errors:

Quote:

Warning: Missing argument 1 for Net_Ping::Net_Ping(), called in C:\Servers\HTTP\Apache\Apache2\htdocs\test\ping_test.php on line 12 and defined in c:\Servers\php5\PEAR\Net\Ping.php on line 135

Warning: Missing argument 2 for Net_Ping::Net_Ping(), called in C:\Servers\HTTP\Apache\Apache2\htdocs\test\ping_test.php on line 12 and defined in c:\Servers\php5\PEAR\Net\Ping.php on line 135
Unreachable

Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Feb 04, 2007 8:57 pm    Post subject: Reply with quote

You get the error messages because the constructor of the class expects two parameters. A short look into the manual will tell you how can solve this problem:
http://pear.php.net/manual/en/package.networking.net-ping.net-ping.php
Back to top
View user's profile Send private message
isurkov



Joined: 04 Feb 2007
Posts: 3

PostPosted: Sun Feb 04, 2007 9:37 pm    Post subject: Reply with quote

mark wrote:
You get the error messages because the constructor of the class expects two parameters. A short look into the manual will tell you how can solve this problem:
http://pear.php.net/manual/en/package.networking.net-ping.net-ping.php


i knew it! And i allready tried to add parameters. For example:

Code:

<?php

require 'Net/Ping.php';
$ping = Net_Ping::factory();

if($ping->checkHost('www.yahoo.com'))
{print 'Reachable';}
else
{print 'Unreachable';}

$data = $ping->ping('www.yahoo.com');
?>



And i get another error:

Quote:


Fatal error: Cannot use object of type Net_Ping_Result as array in C:\Servers\php5\PEAR\Net\Ping.php on line 385
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Feb 04, 2007 9:53 pm    Post subject: Reply with quote

This seems to be a bug in Net_Ping, your code looks right.

checkHost() calls internally ping() which returns an object, but checkHost() assumes then later that it gets an array from ping().

You can report a bug here on (*), but the package seems to be unmaintained, as there are many open and very old bug reports. If you're interested, you could take over the package, of course.

(*) http://pear.php.net/package/Net_Ping
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Networking All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software