#! 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"; } #### #! perl -slw use strict; use threads; use threads::shared; use IO::Socket; $|++; my $bytes1 :shared = 0; my $bytes2 :shared = 0; my $client1 = async{ my $tid = threads->tid; my $svr = new IO::Socket::INET( 'localhost:12345' ) or die "Failed to connect to port: $!\n"; while( 1 ) { my $buffer = <$svr>; $bytes1 += length( $buffer ); } }; my $client2 = async{ my $svr = new IO::Socket::INET( 'localhost:12346' ) or die "Failed to connect to port: $!\n"; while( 1 ) { my $buffer = <$svr>; $bytes2 += length( $buffer ); } }; my( $last1, $last2 ) = (0,0); while( sleep 1 ) { my( $latest1, $latest2 ) = ( $bytes1 , $bytes2 ); printf "\rc1:%5d (%.3f Megabtes/second) c2:%5d (%.3f Megabtes/second)", $latest1, ( $latest1 - $last1 ) / 1024**2, $latest2, ( $latest2 - $last2 ) / 1024**2; ( $last1, $last2 ) = ( $latest1, $latest2 ); } #### C:\test>junk62 c1:12559855306 (54.000 Megabtes/second) c2:12407811641 (53.000 Megabtes/second)