- #!/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.phpxs.com/code/1006387/