in reply to Socket IO problems

When you read from TCP socket, you may receive the message in pieces(, but they are in the right order). Do multiple reads, until you detect the predeined end of msg. This is normal.

Update:

I tested with three different ways to read from a socket, read, sysread, and recv, and found read actually gave you a much better chance to recv the whole packet in one call.

use strict; use IO::Socket; my $server = IO::Socket::INET->new(Proto => "tcp", PeerPort => 80, PeerAddr => "www.yahoo.com", Timeout => 2000) || die "failed to connect\n"; my $req = "GET / HTTP/1.1\r\nHost: www.yahoo.com\r\n\r\n"; print $server $req; my $count = 0; while (1) { my $req; #$server->recv($req, 700000); read($server, $req, 700000); #sysread($server, $req, 700000); print "packet rcvd:\n", substr($req, 0, 20), "\n"; print "packet count = ", ++ $count, "\n"; exit if ($req eq ""); }