Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Need Help On the Socket Connection.

by Caillte (Friar)
on May 15, 2002 at 16:54 UTC ( #166785=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://166785]
[LanX]: but do you have a car?
[TCLion]: Ok I have used SoPW, any feedback would be appreciated
[Eily]: yes, but if you have to borrow it please don't leave any parselmouth stains on it!
[TCLion]: was wondering why is the code window so small for SoPW?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2017-03-23 17:58 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (292 votes). Check out past polls.