private ReceiveTuple doReceiveNonblockTuple(Ruby runtime, int length) throws IOException { DatagramChannel channel = (DatagramChannel)getChannel(); synchronized (channel.blockingLock()) { boolean oldBlocking = channel.isBlocking(); channel.configureBlocking(false); try { return doReceiveTuple(runtime, length); } finally { channel.configureBlocking(oldBlocking); } } }
private ReceiveTuple doReceiveNonblockTuple(Ruby runtime, int length) throws IOException { DatagramChannel channel = (DatagramChannel)getChannel(); synchronized (channel.blockingLock()) { boolean oldBlocking = channel.isBlocking(); channel.configureBlocking(false); try { return doReceiveTuple(runtime, length); } finally { channel.configureBlocking(oldBlocking); } } }
private static ReceiveTuple doReceiveNonblockTuple(RubyBasicSocket socket, Ruby runtime, int length) throws IOException { DatagramChannel channel = (DatagramChannel) socket.getChannel(); synchronized (channel.blockingLock()) { boolean oldBlocking = channel.isBlocking(); channel.configureBlocking(false); try { return doReceiveTuple(socket, runtime, true, length); } finally { channel.configureBlocking(oldBlocking); } } }
private static ReceiveTuple doReceiveNonblockTuple(RubyBasicSocket socket, Ruby runtime, int length) throws IOException { DatagramChannel channel = (DatagramChannel) socket.getChannel(); synchronized (channel.blockingLock()) { boolean oldBlocking = channel.isBlocking(); channel.configureBlocking(false); try { return doReceiveTuple(socket, runtime, true, length); } finally { channel.configureBlocking(oldBlocking); } } }
public static IRubyObject recvfrom(RubyBasicSocket socket, ThreadContext context, IRubyObject length) { final Ruby runtime = context.runtime; try { ReceiveTuple tuple = doReceiveTuple(socket, runtime, false, RubyNumeric.fix2int(length)); IRubyObject addressArray = socket.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) { // SocketException throw runtime.newIOErrorFromException(e); } catch (RaiseException e) { throw e; } catch (Exception e) { throw sockerr(runtime, e.getLocalizedMessage(), e); } }
public static IRubyObject recvfrom(RubyBasicSocket socket, ThreadContext context, IRubyObject length) { final Ruby runtime = context.runtime; try { ReceiveTuple tuple = doReceiveTuple(socket, runtime, false, RubyNumeric.fix2int(length)); IRubyObject addressArray = socket.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) { // SocketException throw runtime.newIOErrorFromException(e); } catch (RaiseException e) { throw e; } catch (Exception e) { throw sockerr(runtime, e.getLocalizedMessage(), e); } }
/** * 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"); } }
/** * 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"); } }