public IRubyObject recv(IRubyObject[] args) {
return recv(getRuntime().getCurrentContext(), args);
}
@JRubyMethod(rest = true)
public IRubyObject recv(ThreadContext context, IRubyObject[] args) {
OpenFile openFile = getOpenFileChecked();
try {
context.getThread().beforeBlockingCall();
return RubyString.newString(context.getRuntime(), openFile.getMainStreamSafe().read(RubyNumeric.fix2int(args[0])));
} catch (BadDescriptorException e) {
throw context.getRuntime().newErrnoEBADFError();
} catch (EOFException e) {
// recv returns nil on EOF
return context.getRuntime().getNil();