New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket read does not "returns $bytes bytes". #3020
Comments
From @bbkrThere was socket behavior change between Rakudo 2012.11 and 2012.12 that caused failure of many modules. It is discussed here: parrot/parrot#909 Current Perl 6 spec says that read($bytes) "Reads and returns $bytes bytes from the handle". But after change it returns only one chunk if desired $bytes count is higher than chunk size. To reproduce: * run following simple server that returns 2KB of data perl6 -e 'my $listener = IO::Socket::INET.new( localhost => "", localport => 8080, :listen ); while my $connection = $listener.accept( ) { $connection.send( "x" x 2048 ); $connection.close( ); }' * and then try to read them 2012.11 is getting whole 2KB: while 2012.12 is getting only 256 bytes Non-continous data flow is also broken: * run following simple server that returns 8 bytes of data in 2 byte chunks perl6 -e 'my $listener = IO::Socket::INET.new( localhost => "", localport => 8080, :listen ); while my $connection = $listener.accept( ) { for ^4 { $connection.send( "xx" ); sleep 1;}; $connection.close( ); }' 2012.11 waits for desired amount of data to be available and returns 8 bytes $ time perl6 -e 'my $client = IO::Socket::INET.new( host => "localhost", port => 8080 ); my $buf = $client.read(8); $buf.bytes.say' while 2012.12 gets only first batch available on socket $ perl6 -e 'my $client = IO::Socket::INET.new( host => "localhost", port => 8080 ); my $buf = $client.read(8); $buf.bytes.say' |
From @bbkr<rurban> bbkr: Looks like parrot wants to follow the established POSIX and perl5 behaviour. So for now there is discrepancy between Rakudo behavior and Perl 6 spec. Either wrapper |
The RT System itself - Status changed from 'new' to 'open' |
From @FROGGSIf we need to patch rakudo I would recommend to keep simple things |
From @FROGGSout of the today's irclog: <supernovus> Hmm, HTTP::Easy depends on the get() method working So if somebody doesnt know the chunk size, (s)he will be unable to use last if $data < $chunk-size But what if other implementations like niecza or jakudo will have a |
From @moritzOn Sat Jan 05 01:10:17 2013, FROGGS.de wrote:
If one doesn't know how much data to expect, one simply uses .recv. |
From @jnthnOn Thu Jan 10 04:43:32 2013, moritz wrote:
By now, things have been sorted out so that: * read will do repeated socket reads to get sufficient data to meet what was requested, unless the connection is closed in which case it can return less; it'll never return more * recv will only ever do one actual recv on the socket, so if one read does not produce enough data, you'll just get a short result; the optional argument serves as an upper limit And these days, recv has a :bin parameter. Tests codifying this behavior in S32-io/socket-recv-vs-read.t. |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#116288 (status was 'resolved')
Searchable as RT116288$
The text was updated successfully, but these errors were encountered: