abachus has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to write a routine to read all the data from a socket or filehandle. The reference is passed to the routine and the read data is returned to the caller. That much is obvious. So far things seem to work ok, but i'd like to be sure this is water tight.
sub Socket_Read { my $Socket = shift; my $ibits = ''; my $Read_Data; vec($ibits,fileno($Socket),1) = 1; while(select($ibits,undef,undef,0.2)) { last if(!sysread($Socket,my $Input,8192)); $Read_Data .= $Input; } return($Read_Data); }
Please, if you know a better way to do this i'm all ears. thank you in advance,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: while(select())
by Anonymous Monk on Oct 16, 2006 at 13:49 UTC | |
|
Re: while(select())
by caelifer (Scribe) on Oct 16, 2006 at 19:31 UTC |