这有点简单,不过却够你想半天。

silicon_crystal 2002-10-11 07:02:02
以下是我的命令行拷贝,请各位帮我看看为什么不对。

G:\work\perl>type tt.pl
use Net::Ping;
$host="61.128.128.68";
$p = Net::Ping->new();
print "$host is alive.\n" if $p->ping($host);
$p->close();

G:\work\perl>ping 61.128.128.68

Pinging 61.128.128.68 with 32 bytes of data:

Reply from 61.128.128.68: bytes=32 time<10ms TTL=252
Reply from 61.128.128.68: bytes=32 time<10ms TTL=252
Reply from 61.128.128.68: bytes=32 time=10ms TTL=252
Reply from 61.128.128.68: bytes=32 time=11ms TTL=252

Ping statistics for 61.128.128.68:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 11ms, Average = 5ms

G:\work\perl>perl tt.pl

G:\work\perl>

为什么我使用tt.pl这个程序后没有报告我说这个站点活着。
...全文
41 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
52cgi 2002-10-12
  • 打赏
  • 举报
回复
学习...
52cgi 2002-10-12
  • 打赏
  • 举报
回复
D_Q(A.Dai)(阿呆)兄真强啊...
silicon_crystal 2002-10-11
  • 打赏
  • 举报
回复
The Unsupported function alarm function is unimplemented at d:/perl/lib/Net/Ping.pm line 308.

我使用你上面程序出现的问题.
我更新过我的net::ping模块了.
D_Q 2002-10-11
  • 打赏
  • 举报
回复
你 $p = Net::Ping->new(); 默认发送的是UDP包
$p=Net::Ping->new(); #UDP
$p=Net::Ping->new('TCP'); #TCP
$p=Net::Ping->new('icmp'); #ICMP
而 Dos下的Ping 是ICMP 呀 不一样
#---------------------------------------------------------------
my $p = Net::Ping->new('tcp');
unless (defined $p) { die "can't create Net::Ping object $!";}
if ($p->ping($host))
{
print "$host TCP有响应\n" ;
}
else
{
print "$host TCP包无响应\n";
}
$p->close;
sleep(1);
#---------------------------------------------------------------
$p = Net::Ping->new();
unless (defined $p) { die "can't create Net::Ping object $!";}
eval {
if ($p->ping($host)) {
print "$host UDP有响应\n" ;
}
else
{
print "$host UDP包无响应\n";
}
}; ## eval
if ($@) {
print "$@\n";
print "udp failed\n";
}
undef $p;
sleep(1);
#---------------------------------------------------------------
if ($> == 0) {
$p = Net::Ping->new('icmp');
unless (defined $p) { die "can't create Net::Ping object $!";}
if ($p->ping($host)) {
print "$host ICMP有响应\n" ;
}
else
{
print "$host ICMP包无响应\n";
}
undef $p;
}
#---------------------------------------------------------------
D_Q 2002-10-11
  • 打赏
  • 举报
回复
据说Net::Ping老版本 不提供TCP 的 Ping 可能Win32的都是 老版本的吧 所以才提示错误(我的个人猜测) 在win32下 我也没有测试成功. UDP ICMP都没问题
D_Q 2002-10-11
  • 打赏
  • 举报
回复
这么改:
use Net::Ping;
$host="61.128.128.68";
$p = Net::Ping->new('icmp');
print "$host is alive.\n" if $p->ping($host);
$p->close();
yakai 2002-10-11
  • 打赏
  • 举报
回复
The same to silicon_crystal

2,204

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧