in reply to Getting sysread to read the full packet

Why are you testing while ($bytes_read == 1024) and not simply while ($bytes_read), which would continue as long as at least one byte has been read...?

P.S.: are you aware that there are higher level modules such as LWP for doing HTTP, which encapsulate all those nasty little details?