perl多线程ping检测C段存活主机

perl多线程ping检测C段存活主机,第1张

概述看了一些前辈的多线程文章,感觉理解了差不多了。就写了这个小程序。 这个程序有点乱,不过没有时间整理写注释,回头有空写成mode吧。 #!/usr/bin/perluse threads;use Net::Ping;$p=Net::Ping->new();sub slep_ping{ local($host_ip)=shift; if($p->ping($host_i

看了一些前辈的多线程文章,感觉理解了差不多了。就写了这个小程序。

这个程序有点乱,不过没有时间整理写注释,回头有空写成mode吧。

#!/usr/bin/perluse threads;use Net::Ping;$p=Net::Ping->new();sub slep_Ping{  local($host_ip)=shift;  if($p->Ping($host_ip))  {     print "$host_ip is access---------OK!\n";  }else{     print "$host_ip is No access\n";  }  $p->close();}sub ip_count{  while($ip_start != $ip_end){    push @ip_group,("$ip."."$ip_start");    $ip_start++;  }  return @ip_group;}system('clear');print "please set the IP(C):";chomp($ip=<STDIN>);print "StartIP:";chomp($ip_start=<STDIN>);print "EndIP:";chomp($ip_end=<STDIN>);my $thread_num=0;&ip_count;foreach $key (@ip_group){   if($thread_num >= 200){        for my $t (threads->List(threads::joinable)){               $t->join();               $thread_num--;        }        redo;   }   threads->create(\&slep_Ping,$key);   $thread_num++;}for my $t(threads->List()){   $t->join;}
总结

以上是内存溢出为你收集整理的perl多线程ping检测C段存活主机全部内容,希望文章能够帮你解决perl多线程ping检测C段存活主机所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1278236.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存