K
kazaam
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?
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?