Skip to content
Browse files

switch IO::Socket.recv to character semantics

this makes the tests not abort on linux, but the tests need adapting
  • Loading branch information...
1 parent d4435ab commit 0392a80820f8c3848852832544028d3e57353c99 @moritz moritz committed Jul 25, 2012
Showing with 11 additions and 5 deletions.
  1. +11 −5 src/core/IO/Socket.pm
View
16 src/core/IO/Socket.pm
@@ -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;

0 comments on commit 0392a80

Please sign in to comment.
Something went wrong with that request. Please try again.