내 솔루션은 ...이 기능을 사용하여 외부 장치에서 ping을 확인했습니다.
function icmpChecksum($data){
if (strlen($data)%2)
$data .= "\x00";
$bit = unpack('n*', $data);
$sum = array_sum($bit);
while ($sum >> 16)
$sum = ($sum >> 16) + ($sum & 0xffff);
return pack('n*', ~$sum);
}
// Making the package
$type= "\x08";
$code= "\x00";
$checksum= "\x00\x00";
$identifier = "\x00\x00";
$seqNumber = "\x00\x00";
$data= "Scarface";
$package = $type.$code.$checksum.$identifier.$seqNumber.$data;
$checksum = icmpChecksum($package); // Calculate the checksum
$package = $type.$code.$checksum.$identifier.$seqNumber.$data;
// And off to the sockets
$socket = socket_create(AF_INET, SOCK_RAW, 1);
socket_set_option ($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>1, "usec"=>0));
socket_connect($socket, 192.168.0.1, null);
$startTime = microtime(true);
socket_send($socket, $package, strLen($package), 0);
if (false === (@socket_read($socket, 255))) {
echo "Harddware is OFF--->";
} else {
echo "Harddware is ON--->";
}
그 날 :)에 대한 불안정 총이었다 그래서 임 쉘 기능으로 고전 핑 (ping)을 사용하는 경우
['is_file()'(http://www.php.net/manual/en/function .is-file.php)/['file_exists()']] (http://www.php.net/manual/en/function.file-exists.php)? – Passerby
파일/exists()는 로컬 파일에만 사용되지만 외부 파일 (예 : http : //domain/fresh.xml) – Blooder
을 검사해야합니다. 외부 서버를 수정할 수 없다면 "짧은 시간 "솔루션을 로컬로 사용하면 어떤 병목 방법을 사용해도 외부 서버와 통신하는 데 소요되는 시간이 주요 병목 현상이라고 생각합니다. – Passerby