Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update IO::Socket for updated Buf.
  • Loading branch information
jnthn committed Jul 21, 2013
1 parent 3300512 commit 28ebf0f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/core/IO/Socket.pm
Expand Up @@ -27,9 +27,7 @@ my role IO::Socket does IO {
}

if $bin {
my $buf := Buf.new;
nqp::bindattr_s($buf, Buf, '$!buffer', nqp::unbox_s($rec));
$buf
nqp::encode(nqp::unbox_s($rec), 'binary', buf8.new);
}
else {
$rec
Expand All @@ -38,14 +36,13 @@ my role IO::Socket does IO {

method read(IO::Socket:D: Cool $bufsize as Int) {
fail('Socket not available') unless $!PIO;
my $res = Buf.new;
my $res = buf8.new;
my $buf;
repeat {
$buf := nqp::create(Buf);
$buf := buf8.new;
my Mu $parrot_buf := pir::new__PS('ByteBuffer');
pir::set__vPS($parrot_buf, $!PIO.read(nqp::unbox_i($bufsize - $res.elems)));
nqp::bindattr_s($buf, Buf, '$!buffer',
$parrot_buf.get_string('binary'));
nqp::encode($parrot_buf.get_string('binary'), 'binary', $buf);
$res = $res ~ $buf;
} while $res.elems < $bufsize && $buf.elems;
$res;
Expand All @@ -63,9 +60,9 @@ my role IO::Socket does IO {
$!PIO.send(nqp::unbox_s($string)).Bool;
}

method write(Buf:D $buf) {
method write(Blob:D $buf) {
fail('Socket not available') unless $!PIO;
$!PIO.send(nqp::unbox_s( $buf.decode('binary') )).Bool;
$!PIO.send(nqp::unbox_s(nqp::decode(nqp::decont($buf), 'binary') )).Bool;
}

method close () {
Expand Down

0 comments on commit 28ebf0f

Please sign in to comment.