my $sock = new IO::Socket::INET->new( # open up a socket to the testing server PeerAddr => 'vm1.naxxtor.com', PeerPort => '80', Proto => 'tcp', Type => SOCK_STREAM ) or die("Can't open socket $!"); print "Sending request\n"; print $sock $request; # send the request for the test file print "Starting transfer\n"; { local $| = 1; my $chunk_start = 0; # initialise some variables my $chunk_time = 0; local $/ = \10240; # read in chunks 10240 bytes long $chunk_start = [gettimeofday]; # set initial timer while (<$sock>) { # loop through each chunk $chunk_time = tv_interval($chunk_start); # calculate the time taken to download this chunk. if ($chunk_time != 0) { push(@speeds,$chunk_time); } $chunk_start = [gettimeofday]; } }