kruvas - 2012-02-20 12:28:11
if socket_create disabled, class not died and continue work and show could not connect to ... (if not defined source ip)
or die Couldn't bind socket: permission denied
i suggets add on top of ping function check for socket creating succesfull
function Ping($dst_addr, $src_addr="", $timeout=5, $precision=3) {
// check for socket existance
if ($this->icmp_socket===false)
{
$this->errstr = socket_strerror(socket_last_error());
die("socket_create() failed: reason: " . $this->errstr);
}
also some semantics:
replace constant
$this->icmp_socket = socket_create(AF_INET, SOCK_RAW, 1);
with
$this->icmp_socket = socket_create(AF_INET, SOCK_RAW, getprotobyname('icmp'));
удачи )