首页 电脑 电脑学堂 查看内容

PHP实现ping代码

2009-8-28 11:05 505 0

摘要: <? //PHP Ping by fvox  function ping($host){     $suck = socket_create(AF_INE...

<? //PHP Ping by fvox  function ping($host){     $suck = socket_create(AF_INET, SOCK_RAW, getprotobyname("ICMP"));     $stime = array_sum(explode(" ", microtime()));     socket_sendto($suck, "\x08\x00\x19\x2f\x00\x00\x00\x00ping", 12, 0x4, $host, 4242);     socket_read($suck, 512);     $etime = array_sum(explode(" ", microtime()));     socket_close($suck);     $time = $etime - $stime;      if(!is_float($time))         return false;     else         return substr($time, 3, 2); }  echo ping("www.google.com");  ?>
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部