All pastes #186362 Raw Edit

Miscellany

public text v1 · immutable
#186362 ·published 2006-09-29 20:53 UTC
rendered paste body
#!/usr/bin/perl

use warnings;
use strict;
use IO::Socket::INET;

my $start = 8801;
my $max   = 9000;
my @_fh   = ();

for ( $start .. $max ) {
    $_fh[$_] = IO::Socket::INET->new(
        LocalPort   =>  $_,
        LocalAddr   =>  'localhost',
        Proto       =>  'tcp',
        Listen      =>  SOMAXCONN
    ) or die "Couldn't bind to port $_ : $!\n";
}

sleep 60;

foreach my $fd ( @_fh ) { $fd && close( $fd ) }