in reply to Re^6: IO::Socket Listen
in thread IO::Socket Listen
When you know the length of the expected response (such as 131), you can concat the pieces you get from sysread and check if the resulting string has reached that length. I said "pieces" because in theory (for example, if the connection has temporarily stalled for some reason), sysread might return prematurely with less than the requested number of bytes. So, to be sure, you'd need some loop + concat:
my $len = 131; my $resp = ''; while ( sysread $socket, $_, $len ) { $repsp .= $_; last if length($resp) >= $len; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: IO::Socket Listen
by Secalles (Initiate) on Dec 07, 2011 at 11:29 UTC | |
by Marshall (Canon) on Dec 08, 2011 at 06:55 UTC | |
by Eliya (Vicar) on Dec 08, 2011 at 08:53 UTC | |
by Marshall (Canon) on Dec 08, 2011 at 12:08 UTC | |
by Secalles (Initiate) on Dec 09, 2011 at 12:54 UTC | |
|