in reply to IO:Socket::INET - how to receive binary data
my $answer = <$remote> || '---';
my $header; $remote->read($header, 8); ($op, $hvers, undef, undef, $count) = unpack "C4N", $header; my $data; $remote->read($data, $count);
If you want to mix the read idioms (per tye's suggestion) (of course, this assumes you can't have embedded \n in your data), you can do it this way:
my $header; $remote->read($header, 8); ($op, $hvers, undef, undef, $count) = unpack "C4N", $header; my $data = <$remote>;
update: changed to mention read and show mixture of idioms (thanks tye!), attribute to tye correctly
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: IO:Socket::INET - how to receive binary data
by Aighearach (Initiate) on Jun 24, 2001 at 06:39 UTC | |
by tye (Sage) on Jun 24, 2001 at 09:56 UTC | |
|
Re: Re: IO:Socket::INET - how to receive binary data
by Rudif (Hermit) on Jun 25, 2001 at 03:23 UTC |