in reply to Reading Binary Data via socket ( Converting program from java to perl )

Since it's using readInt, I'm assuming the int gets passed back in plain text with a newline to end it.

No. ReadInt() reads binary data, not ASCIIfied. See ReadInt(). The (roughly) equivalent code in Perl would be:

if( $more ) { syswrite( OUT, 1, chr( 64 ) ); $more = 0; } sysread( IN, 4, my $buf ); my $size = unpack( 'N', $buf ); ## Or 'V' see perlfunc:pack my $imgData; sysread( IN, $size, $imgData );

That's only vaguely equivalent. Your snippet does not show what in, out or more are, so you'll need to work that out for yourself. It looks vaguely as if they are separate input and output handles to a socket stream or pipe, but that's guessing.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon