Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =item How do I read data until the other side closes the connection?
- If you just want to read your data into a perl scalar, the easiest way
- to achieve this is by setting an C<on_read> callback that does nothing,
- clearing the C<on_eof> callback and in the C<on_error> callback, the data
- will be in C<$_[0]{rbuf}>:
- $handle->on_read (sub { });
- $handle->on_eof (undef);
- $handle->on_error (sub {
- my $data = delete $_[0]{rbuf};
- });
- The reason to use C<on_error> is that TCP connections, due to latencies
- and packets loss, might get closed quite violently with an error, when in
- fact, all data has been received.
Add Comment
Please, Sign In to add comment