in reply to
client server file transfer
If you have full control over the protocol and both client
and server implementation then I would consider a different
method. It would be possible to continue using a end tag, but
it can be difficult to do that correctly and reliably without
fiddling with various selects and reading methods and hoping that piece of data
won't appear in the file.
Alternativly I would do what some protocols do and use a
message content length (in exact bytes) so that the reciver
knows exactly how much binary data to read, after which normal
operation can resume.
For this you could just add a line to the sender to like
print OUT "Size: " . (-s $file) . "\n"; and the
reciver can parse that line of data and use one or a series of read
statements to recieve exactly that much data.