php恐怕做不到,php是用来做http服务的,可以用一些类似网吧管理的软件统计

解决方案 »

  1.   

    试试看,如果要VC代码说一声gethostbyaddr
    传回机器名称。语法: string gethostbyaddr(string ip_address);传回值: 字串函式种类: 网路系统
     
     
    内容说明 
    本函式可传回某个 IP 网址的机器名称 (Domain Name)。若执行失败,则传回原来的 IP 网址。
     
     
    使用范例 
    下例的传回值为 dns.biglobe.net.tw<?
    echo gethostbyaddr("202.166.255.97");
    ?> 
      

  2.   

    可以用socket函数啊,试着用
    int fsockopen(string hostname, int port, int [errno], string [errstr], int [timeout]);
    这个函数
    联一个网址,如www.163.com的http服务的80端口,
    如 
    <?if (@fsockopen("www.163.com",80, &$errno, &$errstr))
    echo "成功联上互联网";
    else
    echo ("无法联上互联网,出错原因:$errstr,代码:$errno");
    ?>
    本方法成功通过编译
    联不上www.163.com应该算联不上互联网了
    如果觉得163不够的话,把if的条件改为
    (@fsockopen("www.163.com",80, &$errno, &$errstr)||(@fsockopen("www.sohu.com",80, &$errno, &$errstr))
    这样绝对保险
    因为两个网站不可能同时出问题,如果两个都联不上,呵只能是你机器的原因了,
      

  3.   

    asphp(李雄政) :
    好像可以,但是当联不网时的判断太慢了,10分还没出来,等不急了,我又插上网线了,呵呵,:}
      

  4.   

    呵呵,我调试的时候是在linux的机器上,PIV1.6G+512M
    对不起,我再看看
      

  5.   

    刚才看了一下英文资料,关于fsockopen,后面可以接一个float timeout;
    int fsockopen ( string hostname, int port [, int errno [, string errstr [, float timeout]]])
    if 条件改为
    (@fsockopen("www.163.com",80, &$errno, &$errstr,1)||(@fsockopen("www.sohu.com",80, &$errno, &$errstr,1))
    呵呵,即最大允许timeout为1 second
      

  6.   

    即使能实现这个功能,但由谁来运行这个 PHP 文件?
    是用户吗?在每次断网前...让用户在地址栏里 输入:
    http://xxx.xxx.xxx.xxx/offline.php
    ????不太可能吧。
      

  7.   

    参考《UNIX NETWORK PROGAMMING》UNIX网络编程
    清华大学出版社  英文(影印版)