Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (31 sloc) 0.689 kb
use strict;
use warnings;
use Getopt::Long;
use forks;
use IO::Socket::INET;
my $concurrent = 10;
my $port = 9090;
GetOptions(
'concurrent=s' => \$concurrent,
'port=i' => \$port,
);
my $sock = IO::Socket::INET->new(
LocalHost => '0.0.0.0',
LocalPort => $port,
Listen => 10,
ReuseAddr => 1
) or die $!;
my @threads;
for my $i (1..$concurrent) {
push @threads, threads->create(sub {
while (1) {
my $csock = $sock->accept;
while (my $line = <$csock>) {
print $csock $line;
}
}
});
}
print "ithread: http://localhost:$port/\n";
print "concurrency: $concurrent\n";
$_->join for @threads;
Jump to Line
Something went wrong with that request. Please try again.