in reply to Need Help On the Socket Connection.
If, as I assume, your error conditions will be on a line of their own, try this:
sub SOCKETread{ my $s = $_[0]; my $buffer = ""; my ($ready, $fdmask, $nfound); $buffer = read_line($s); # do stuff with buffer return $buffer; } sub read_line { my $s = shift; my $maxline = 50; my $buffer = ''; my ($buf, $bytesread); do { $bytesread = sysread($s, $buf, $maxline); $buffer .= $buf; } while($bytesread == $maxline and $buffer !~ /\n$/); return $buffer; }
I didn't have time to test this, sorry, but it should work as shown
Update:Put correct test in the while statement.
This page is intentionally left justified.
|
---|