in reply to How to make EOF?
If you need the other end to read multiple files then you'll need to rely on some convention. Personally I prefer to prefix potentially long transmissions with the size of the transmission rather than relying a special character which could someday appear by accident in the data stream. For example on the sending side:
print WRITER length($yaml), "\n", $yaml;
Then the reader can do:
my $length = <READER>; chomp($length); my $buffer = ""; while(length $buffer < $length and not eof(READER)) { read(READER, $buffer, 4048, length $buffer); } # do something with the YAML data in buffer...
Possibly interesting side-note - I was just reading the memcached protocol spec and this is exactly how it works too.
-sam
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to make EOF?
by roboticus (Chancellor) on Mar 04, 2009 at 21:21 UTC |