private UnixServerSocketChannel asUnixServer() { return (UnixServerSocketChannel)getChannel(); } }// RubyUNIXServer
private UnixServerSocketChannel asUnixServer() { return (UnixServerSocketChannel)getChannel(); } }// RubyUNIXServer
@Override protected UnixSocketAddress getUnixRemoteSocket() { SocketAddress socketAddress = ((UnixServerSocketChannel)getChannel()).getLocalSocketAddress(); if (socketAddress instanceof UnixSocketAddress) return (UnixSocketAddress) socketAddress; return null; }
@Override protected UnixSocketAddress getUnixSocketAddress() { SocketAddress socketAddress = ((UnixServerSocketChannel)getChannel()).getLocalSocketAddress(); if (socketAddress instanceof UnixSocketAddress) return (UnixSocketAddress) socketAddress; return null; }
@Override protected UnixSocketAddress getUnixSocketAddress() { SocketAddress socketAddress = ((UnixServerSocketChannel)getChannel()).getLocalSocketAddress(); if (socketAddress instanceof UnixSocketAddress) return (UnixSocketAddress) socketAddress; return null; }
@Override protected UnixSocketAddress getUnixRemoteSocket() { SocketAddress socketAddress = ((UnixServerSocketChannel)getChannel()).getLocalSocketAddress(); if (socketAddress instanceof UnixSocketAddress) return (UnixSocketAddress) socketAddress; return null; }
public IRubyObject accept_nonblock(ThreadContext context, Ruby runtime, boolean ex) { SelectableChannel selectable = (SelectableChannel)getChannel(); synchronized (selectable.blockingLock()) { boolean oldBlocking = selectable.isBlocking(); try { selectable.configureBlocking(false); try { UnixSocketChannel socketChannel = ((UnixServerSocketChannel) selectable).accept(); if (socketChannel == null) { if (!ex) return runtime.newSymbol("wait_readable"); throw runtime.newErrnoEAGAINReadableError("accept(2) would block"); } RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.init_sock(context.runtime, socketChannel, ""); return sock; } finally { selectable.configureBlocking(oldBlocking); } } catch (IOException ioe) { if (ioe.getMessage().equals("accept failed: Resource temporarily unavailable")) { if (!ex) return runtime.newSymbol("wait_readable"); throw runtime.newErrnoEAGAINReadableError("accept"); } throw context.runtime.newIOErrorFromException(ioe); } } }
public IRubyObject accept_nonblock(ThreadContext context, Ruby runtime, boolean ex) { SelectableChannel selectable = (SelectableChannel)getChannel(); synchronized (selectable.blockingLock()) { boolean oldBlocking = selectable.isBlocking(); try { selectable.configureBlocking(false); try { UnixSocketChannel socketChannel = ((UnixServerSocketChannel) selectable).accept(); if (socketChannel == null) { if (!ex) return runtime.newSymbol("wait_readable"); throw runtime.newErrnoEAGAINReadableError("accept(2) would block"); } RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.init_sock(context.runtime, socketChannel, ""); return sock; } finally { selectable.configureBlocking(oldBlocking); } } catch (IOException ioe) { if (ioe.getMessage().equals("accept failed: Resource temporarily unavailable")) { if (!ex) return runtime.newSymbol("wait_readable"); throw runtime.newErrnoEAGAINReadableError("accept"); } throw context.runtime.newIOErrorFromException(ioe); } } }