Gutek, mi nie chodziło o pierwszy post, tylko drugi w drugim masz link,
a w sumie masz, dzisiaj za dobry jestem:
<?php
// Checksum calculation function
function icmpChecksum($data)
{
$data .= "x00";
while ($sum >> 16)
$sum = ($sum >> 16) + ($sum & 0xffff);
return pack('n*', ~
$sum); }
// Making the package
$type= "x08";
$code= "x00";
$checksum= "x00x00";
$identifier = "x00x00";
$seqNumber = "x00x00";
$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_connect($socket, "www.google.com", null);
// If you're using below PHP 5, see the manual for the microtime_float
// function. Instead of just using the m
// icrotime() function.
socket_send
($socket, $package, strLen($package), 0
); if (socket_read($socket, 255)) {
}
socket_close($socket);
?>
a jak chcesz zmienić adres i port to w linii 28 zamień www.google.com na ip czy adres a null zamień na port
Jak chcesz mieć taki komunikat to w 35 przed round(... a za echo daj "Ping to: ". a zamiast .' seconds' daj .' sekund.
Aha, jak chcesz przeliczyć na ms to zamiast round(microtime(true) - $startTime, 4) daj round(microtime(true) - $startTime, 4)/0,001 ale chyba sekundy ci starczą...
no tyle ci podpowiedziałem że powinieś napisać ten kod bez problemu.
Oczywiście teoretycznie zadziała, ale jak długo będzie ściągał ping to nie wiem