On Oct 6, 2007, at 10:50 AM, kazaam wrote:

> Well I'm trying to "translate" a perl program to ruby and  
> everything worked fine until the near end where I'm now. There we  
> have this perl code:
>
>  my $slct = IO::Select->new($server);
>     while($slct->can_read()) {
>         my $nbytes = read $server, $response, 2**16;
>         last if !$nbytes;
>         $client->send($response);
>     }
>
> $server is a socket-handle exactly as $client. But now I'm stuck.  
> Is there any equivalent to perls can_read ? Than this line here:
>         my $nbytes = read $server, $response, 2**16;
>         last if !$nbytes;
>
> Means something like read from server 2^16 bytes save to nbytes and  
> append to response or?


cfp:~ > ruby -r io/wait -e' p STDIN.ready? '
nil


cfp:~ > ruby -r io/wait -e' p STDIN.ready? ' < /dev/zero
-e:1:in `ready?': Operation not supported by device (Errno::ENODEV)
         from -e:1


cfp:~ > ruby -r io/wait -e' p STDIN.ready? ' < /dev/null
-e:1:in `ready?': Operation not supported by device (Errno::ENODEV)
         from -e:1



cfp:~ > ruby -r io/wait -e' p STDIN.ready? ' < /etc/passwd
1932



a @ http://codeforpeople.com/
--
share your knowledge.  it's a way to achieve immortality.
h.h. the 14th dalai lama