Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can PHP ping a remote system without ICMP and without external programs?

Tags:

php

ping

I want to check if another machine is generally responding with PHP.

Most approaches are to ping some service running on the target machine, but I want to check if the machine is online generally.

I've found http://birk-jensen.dk/2010/09/php-ping/ which supposedly sends an ICMP Ping package. The problem is, somehow one is required to be root to perform a socket_create(AF_INET, SOCK_RAW, 1). The workaround via posix_seteuid(0) doesn't work either, since elevated permissions are required for that too.

Any functions that would let me run the ping program are not available in my scenario either.

So how do I check if a server is online using php?

like image 686
Cobra_Fast Avatar asked Nov 03 '22 08:11

Cobra_Fast


1 Answers

You can always use Net_Ping to ping from php http://pear.php.net/package/Net_Ping/redirected

like image 114
tix3 Avatar answered Nov 13 '22 01:11

tix3