Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'toqast' into nom
  • Loading branch information
jnthn committed Jul 25, 2012
2 parents 48fdb9e + 0392a80 commit ed269f7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/core/IO/Socket.pm
Expand Up @@ -2,13 +2,19 @@ my role IO::Socket {
has $!PIO;
has $!buffer = '';

method recv (Cool $bufsize = $Inf) {
method recv (Cool $chars = $Inf) {
fail('Socket not available') unless $!PIO;

$!buffer ~= nqp::p6box_s($!PIO.recv()) if $!buffer.bytes <= $bufsize
if $!buffer.bytes > $bufsize {
my $rec = $!buffer.substr(0, $bufsize);
$!buffer = $!buffer.substr($bufsize);
if $!buffer.chars < $chars {
my str $r = $!PIO.recv;
$r = pir::trans_encoding__SSI($r,
pir::find_encoding__Is('utf8'));
$!buffer ~= nqp::p6box_s($r);
}

if $!buffer.chars > $chars {
my $rec = $!buffer.substr(0, $chars);
$!buffer = $!buffer.substr($chars);
$rec
} else {
my $rec = $!buffer;
Expand Down

0 comments on commit ed269f7

Please sign in to comment.