@JRubyMethod(name = "sysaccept") public IRubyObject sysaccept(ThreadContext context) { Ruby runtime = context.runtime; try { RubyThread thread = context.getThread(); while (true) { boolean ready = thread.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 { SocketChannel connected = getServerSocketChannel().accept(); if (connected == null) continue; connected.finishConnect(); return runtime.newFixnum(FilenoUtil.filenoFrom(connected)); } } } catch(IOException e) { throw runtime.newIOErrorFromException(e); } }
@JRubyMethod(name = "sysaccept") public IRubyObject sysaccept(ThreadContext context) { Ruby runtime = context.runtime; try { RubyThread thread = context.getThread(); while (true) { boolean ready = thread.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 { SocketChannel connected = getServerSocketChannel().accept(); if (connected == null) continue; connected.finishConnect(); return runtime.newFixnum(FilenoUtil.filenoFrom(connected)); } } } catch(IOException e) { throw runtime.newIOErrorFromException(e); } }
@JRubyMethod(name = "accept") public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; RubyTCPSocket socket = new RubyTCPSocket(runtime, runtime.getClass("TCPSocket")); try { RubyThread thread = context.getThread(); while (true) { boolean ready = thread.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 { SocketChannel connected = getServerSocketChannel().accept(); if (connected == null) continue; connected.finishConnect(); // Force the client socket to be blocking synchronized (connected.blockingLock()) { connected.configureBlocking(false); connected.configureBlocking(true); } // otherwise one key has been selected (ours) so we get the channel and hand it off socket.initSocket(newChannelFD(runtime, connected)); return socket; } } } catch(IOException e) { throw runtime.newIOErrorFromException(e); } }
@JRubyMethod(name = "accept") public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; RubyTCPSocket socket = new RubyTCPSocket(runtime, runtime.getClass("TCPSocket")); try { RubyThread thread = context.getThread(); while (true) { boolean ready = thread.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 { SocketChannel connected = getServerSocketChannel().accept(); if (connected == null) continue; connected.finishConnect(); // Force the client socket to be blocking synchronized (connected.blockingLock()) { connected.configureBlocking(false); connected.configureBlocking(true); } // otherwise one key has been selected (ours) so we get the channel and hand it off socket.initSocket(newChannelFD(runtime, connected)); return socket; } } } catch(IOException e) { throw runtime.newIOErrorFromException(e); } }
@JRubyMethod(name = "accept") public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; RubyTCPSocket socket = new RubyTCPSocket(runtime, runtime.getClass("TCPSocket")); try { RubyThread thread = context.getThread(); while (true) { boolean ready = thread.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 { SocketChannel connected = getServerSocketChannel().accept(); if (connected == null) continue; connected.finishConnect(); // Force the client socket to be blocking synchronized (connected.blockingLock()) { connected.configureBlocking(false); connected.configureBlocking(true); } // otherwise one key has been selected (ours) so we get the channel and hand it off socket.initSocket(runtime, new ChannelDescriptor(connected, newModeFlags(runtime, ModeFlags.RDWR))); return socket; } } } catch(IOException e) { throw SocketUtils.sockerr(runtime, "problem when accepting"); } }
public IRubyObject accept_nonblock(ThreadContext context, Ruby runtime, boolean ex) { RubyTCPSocket socket = new RubyTCPSocket(runtime, runtime.getClass("TCPSocket")); Selector selector = null; ServerSocketChannel ssc = getServerSocketChannel();
public IRubyObject accept_nonblock(ThreadContext context, Ruby runtime, boolean ex) { RubyTCPSocket socket = new RubyTCPSocket(runtime, runtime.getClass("TCPSocket")); Selector selector = null; ServerSocketChannel ssc = getServerSocketChannel();
RubyTCPSocket socket = new RubyTCPSocket(runtime, runtime.getClass("TCPSocket")); Selector selector = null; ServerSocketChannel ssc = getServerSocketChannel();