in reply to Re^3: sysread and syswrite in tcp sockets
in thread sysread and syswrite in tcp sockets

Your code can be better written as

while(1){ my $buffer = ''; my $bytes_read; do { $bytes_read = sysread($sock, $buffer, 64*1024, length($buffer)); } while ($bytes_read && $select->can_read(1)); createFile(<filename>, $buffer, length($buffer), 0); processFile(); }

That whole timeout thing is going to backfire on you. You need to send the length of the file before actually sending the file so you know when to stop reading.