public IRubyObject allocate(Ruby runtime, RubyClass klass) { return new RubyUNIXServer(runtime, klass); } };
@JRubyMethod public IRubyObject sysaccept(ThreadContext context) { return accept(context); }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject path) { init_unixsock(context.runtime, path, true); return this; }
@JRubyMethod public IRubyObject accept_nonblock(ThreadContext context, IRubyObject opts) { return accept_nonblock(context, context.runtime, extractExceptionArg(context, opts)); }
public void load(final Ruby runtime, boolean wrap) throws IOException { runtime.defineClass("SocketError", runtime.getStandardError(), runtime.getStandardError().getAllocator()); RubyBasicSocket.createBasicSocket(runtime); RubySocket.createSocket(runtime); RubyServerSocket.createServerSocket(runtime); if (runtime.getInstanceConfig().isNativeEnabled() && !Platform.IS_WINDOWS) { RubyUNIXSocket.createUNIXSocket(runtime); RubyUNIXServer.createUNIXServer(runtime); } RubyIPSocket.createIPSocket(runtime); RubyTCPSocket.createTCPSocket(runtime); RubyTCPServer.createTCPServer(runtime); RubyUDPSocket.createUDPSocket(runtime); Addrinfo.createAddrinfo(runtime); Option.createOption(runtime); Ifaddr.createIfaddr(runtime); } }
@JRubyMethod public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; try { while (true) { // select loop to allow interrupting boolean ready = context.getThread().select(this, SelectionKey.OP_ACCEPT); if (!ready) { // we were woken up without being selected...poll for thread events and go back to sleep context.pollThreadEvents(); } else { UnixSocketChannel socketChannel = asUnixServer().accept(); RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.channel = socketChannel; sock.fpath = ""; sock.init_sock(context.runtime); return sock; } } } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } }
private UnixServerSocketChannel asUnixServer() { return (UnixServerSocketChannel)getChannel(); } }// RubyUNIXServer
@JRubyMethod public IRubyObject accept_nonblock(ThreadContext context) { return accept_nonblock(context, context.runtime, true); }
public void load(final Ruby runtime, boolean wrap) throws IOException { runtime.defineClass("SocketError", runtime.getStandardError(), runtime.getStandardError().getAllocator()); RubyBasicSocket.createBasicSocket(runtime); RubySocket.createSocket(runtime); RubyServerSocket.createServerSocket(runtime); if (runtime.getInstanceConfig().isNativeEnabled() && !Platform.IS_WINDOWS) { RubyUNIXSocket.createUNIXSocket(runtime); RubyUNIXServer.createUNIXServer(runtime); } RubyIPSocket.createIPSocket(runtime); RubyTCPSocket.createTCPSocket(runtime); RubyTCPServer.createTCPServer(runtime); RubyUDPSocket.createUDPSocket(runtime); if (runtime.is1_9()) { Addrinfo.createAddrinfo(runtime); Option.createOption(runtime); } } }
@JRubyMethod public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; try { while (true) { // select loop to allow interrupting boolean ready = context.getThread().select(this, SelectionKey.OP_ACCEPT); if (!ready) { // we were woken up without being selected...poll for thread events and go back to sleep context.pollThreadEvents(); } else { UnixSocketChannel socketChannel = asUnixServer().accept(); RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.channel = socketChannel; sock.fpath = ""; sock.init_sock(context.runtime); return sock; } } } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } }
@JRubyMethod public IRubyObject accept_nonblock(ThreadContext context, IRubyObject opts) { return accept_nonblock(context, context.runtime, extractExceptionArg(context, opts)); }
private UnixServerSocketChannel asUnixServer() { return (UnixServerSocketChannel)getChannel(); } }// RubyUNIXServer
@JRubyMethod public IRubyObject accept_nonblock(ThreadContext context) { return accept_nonblock(context, context.runtime, true); }
@JRubyMethod public IRubyObject sysaccept(ThreadContext context) { return accept(context); }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject path) { init_unixsock(context.runtime, path, true); return this; }
public IRubyObject allocate(Ruby runtime, RubyClass klass) { return new RubyUNIXServer(runtime, klass); } };
public void load(final Ruby runtime, boolean wrap) throws IOException { runtime.defineClass("SocketError", runtime.getStandardError(), runtime.getStandardError().getAllocator()); RubyBasicSocket.createBasicSocket(runtime); RubySocket.createSocket(runtime); RubyServerSocket.createServerSocket(runtime); if (runtime.getInstanceConfig().isNativeEnabled() && !Platform.IS_WINDOWS) { RubyUNIXSocket.createUNIXSocket(runtime); RubyUNIXServer.createUNIXServer(runtime); } RubyIPSocket.createIPSocket(runtime); RubyTCPSocket.createTCPSocket(runtime); RubyTCPServer.createTCPServer(runtime); RubyUDPSocket.createUDPSocket(runtime); Addrinfo.createAddrinfo(runtime); Option.createOption(runtime); Ifaddr.createIfaddr(runtime); } }
@JRubyMethod public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; try { while (true) { // select loop to allow interrupting boolean ready = context.getThread().select(this, SelectionKey.OP_ACCEPT); if (!ready) { // we were woken up without being selected...poll for thread events and go back to sleep context.pollThreadEvents(); } else { UnixSocketChannel socketChannel = asUnixServer().accept(); RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.init_sock(context.runtime, socketChannel, ""); return sock; } } } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } }
@Override protected UnixSocketAddress getUnixRemoteSocket() { SocketAddress socketAddress = ((UnixServerSocketChannel)getChannel()).getLocalSocketAddress(); if (socketAddress instanceof UnixSocketAddress) return (UnixSocketAddress) socketAddress; return null; }
@JRubyMethod public IRubyObject sysaccept(ThreadContext context) { RubyUNIXSocket socket = (RubyUNIXSocket) accept(context); return context.runtime.newFixnum(((UnixSocketChannel) socket.getChannel()).getFD()); }