Perl 使用 fork 的 socket 服务器

2015-12-14 0 731
Perl 使用 fork 的 socket 服务器
#!/usr/bin/perl
use warnings;
use IO::Socket;
my $servsock = IO::Socket::INET->new( Listen => 5,LocalPort => 5000);
sub reap { 
   wait(); 
   $SIG{CHLD} = \&reap;
} # catch and handle children dying
$SIG{CHLD} = \&reap;
while($client = $servsock->accept()) {
    if ($pid = fork()) {
        close $servsock; 
    } else {
        close $client; #let the child deal with the client socket
    }
}

遇见资源网 perl Perl 使用 fork 的 socket 服务器 http://www.ox520.com/13241.html

上一篇:

已经没有上一篇了!

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务