Web Hosting Talk







View Full Version : PHP ping


TR Seeks
03-30-2005, 03:57 PM
Is there a command to ping via PHP?

I know you can connect to ports etc but is there a command to ping.

If not is there a port which is open on all servers and always up when the server is up?

port 80 for example... but that goes down when http goes down and due to that it can cause fake downtime as such at times of high load when server lags...

ilyash
03-30-2005, 04:03 PM
use the exec function..

and just make the system do "ping ip"

parse the data which is returned, and display it.

TR Seeks
03-30-2005, 04:08 PM
there are many security issues with exec function and as such id rather not use it. Is there any other way...

mfonda
03-30-2005, 05:20 PM
http://pear.php.net/package/Net_Ping

TR Seeks
03-30-2005, 05:35 PM
Thank you Matt, Ill take a look later

hiryuu
03-30-2005, 06:17 PM
Net_Ping still just executes the ping command. Generating ICMP packets requires root access (ping is suid root), which is why there's no native version.

Connecting to a port that is not in use should (firewalls permitting) generate a Connection Refused response. You could time that to get your ping.