你的分享就是我们的动力 ---﹥

一个超级简单的Socket服务器

时间:2013-05-30 00:14来源:www.chengxuyuans.com 点击:

Perl代码片段

#!/usr/bin/perl
use warnings;
use strict;
use IO::Socket;
# queue up no more than 5 pending clients
my $serv = IO::Socket::INET->new(LocalPort => 9876,Listen => 5); 
while(my $client = $serv->accept()) { #somebody connected!
    print $client "The time is now: ".scalar(localtime(time()))."\n";
    close $client;
}

转载注明地址:http://www.chengxuyuans.com/Perl/63119.html