/** * Overrides IPSocket#recvfrom */ @Override public IRubyObject recvfrom(ThreadContext context, IRubyObject _length) { Ruby runtime = context.runtime; try { int length = RubyNumeric.fix2int(_length); ReceiveTuple tuple = doReceiveTuple(runtime, length); IRubyObject addressArray = addrFor(context, tuple.sender, false); return runtime.newArray(tuple.result, addressArray); } catch (UnknownHostException e) { throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known"); } catch (PortUnreachableException e) { throw runtime.newErrnoECONNREFUSEDError(); } catch (IOException e) { throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known"); } }
@JRubyMethod public IRubyObject recvfrom_nonblock(ThreadContext context, IRubyObject _length) { Ruby runtime = context.runtime; try { int length = RubyNumeric.fix2int(_length); ReceiveTuple tuple = doReceiveNonblockTuple(runtime, length); IRubyObject addressArray = addrFor(context, tuple.sender, false); return runtime.newArray(tuple.result, addressArray); } catch (UnknownHostException e) { throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known"); } catch (PortUnreachableException e) { throw runtime.newErrnoECONNREFUSEDError(); } catch (IOException e) { throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known"); } }
/** * Overrides IPSocket#recvfrom */ @Override public IRubyObject recvfrom(ThreadContext context, IRubyObject _length) { Ruby runtime = context.runtime; try { int length = RubyNumeric.fix2int(_length); ReceiveTuple tuple = doReceiveTuple(runtime, length); IRubyObject addressArray = addrFor(context, tuple.sender, false); return runtime.newArray(tuple.result, addressArray); } catch (UnknownHostException e) { throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known"); } catch (PortUnreachableException e) { throw runtime.newErrnoECONNREFUSEDError(); } catch (IOException e) { throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known"); } }
@JRubyMethod public IRubyObject recvfrom_nonblock(ThreadContext context, IRubyObject _length) { Ruby runtime = context.runtime; try { int length = RubyNumeric.fix2int(_length); ReceiveTuple tuple = doReceiveNonblockTuple(runtime, length); IRubyObject addressArray = addrFor(context, tuple.sender, false); return runtime.newArray(tuple.result, addressArray); } catch (UnknownHostException e) { throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known"); } catch (PortUnreachableException e) { throw runtime.newErrnoECONNREFUSEDError(); } catch (IOException e) { throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known"); } }