#! perl -slw use strict; use threads; use threads::shared; use IO::Socket; $|++; my $status1 :shared = 0; my $status2 :shared = 0; my $server1 = async{ my $lsn = new IO::Socket::INET( Listen => 5, LocalPort => '12345' ) or die "Failed to open listening port: $!\n"; my $data = 'x' x 1024**2; while( my $c = $lsn->accept ) { while( 1 ) { print $c $data; ++$status1; } print "client disconnected"; } }; my $server2 = async{ my $lsn = new IO::Socket::INET( Listen => 5, LocalPort => '12346' ) or die "Failed to open listening port: $!\n"; my $data = 'x' x 1024**2; while( my $c = $lsn->accept ) { while( 1 ) { print $c $data; ++$status2; } print "client disconnected"; } }; while( Win32::Sleep 100 ) { printf "\r$status1 : $status2"; }