public ServerSocketChannel openServerSocketChannel() throws IOException { return new ServerSocketChannelImpl(this); }
@Override public Socket accept() throws IOException { if (!channelImpl.isBound) { throw new IllegalBlockingModeException(); } SocketChannel sc = channelImpl.accept(); if (sc == null) { throw new IllegalBlockingModeException(); } return sc.socket(); }
@Override public SocketChannel accept() throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (!isBound) { throw new NotYetBoundException(); } // Create an empty socket channel. This will be populated by ServerSocketAdapter.accept. SocketChannelImpl result = new SocketChannelImpl(provider(), false); try { begin(); synchronized (acceptLock) { try { socket.implAccept(result); } catch (SocketTimeoutException e) { if (shouldThrowSocketTimeoutExceptionFromAccept(e)) { throw e; } // Otherwise, this is a non-blocking socket and there's nothing ready, so we'll // fall through and return null. } } } finally { end(result.socket().isConnected()); } return result.socket().isConnected() ? result : null; }
private boolean shouldThrowSocketTimeoutExceptionFromAccept(SocketTimeoutException e) { if (isBlocking()) { return true; } Throwable cause = e.getCause(); if (cause instanceof ErrnoException) { if (((ErrnoException) cause).errno == EAGAIN) { return false; } } return true; }
private boolean shouldThrowSocketTimeoutExceptionFromAccept(SocketTimeoutException e) { if (isBlocking()) { return true; } Throwable cause = e.getCause(); if (cause instanceof ErrnoException) { if (((ErrnoException) cause).errno == EAGAIN) { return false; } } return true; }
@Override public SocketChannel accept() throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (!isBound) { throw new NotYetBoundException(); } // Create an empty socket channel. This will be populated by ServerSocketAdapter.accept. SocketChannelImpl result = new SocketChannelImpl(provider(), false); try { begin(); synchronized (acceptLock) { try { socket.implAccept(result); } catch (SocketTimeoutException e) { if (shouldThrowSocketTimeoutExceptionFromAccept(e)) { throw e; } // Otherwise, this is a non-blocking socket and there's nothing ready, so we'll // fall through and return null. } } } finally { end(result.socket().isConnected()); } return result.socket().isConnected() ? result : null; }
public ServerSocketChannel openServerSocketChannel() throws IOException { return new ServerSocketChannelImpl(this); }
@Override public Socket accept() throws IOException { if (!channelImpl.isBound) { throw new IllegalBlockingModeException(); } SocketChannel sc = channelImpl.accept(); if (sc == null) { throw new IllegalBlockingModeException(); } return sc.socket(); }
private boolean shouldThrowSocketTimeoutExceptionFromAccept(SocketTimeoutException e) { if (isBlocking()) { return true; } Throwable cause = e.getCause(); if (cause instanceof ErrnoException) { if (((ErrnoException) cause).errno == EAGAIN) { return false; } } return true; }
@Override public SocketChannel accept() throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (!isBound) { throw new NotYetBoundException(); } // Create an empty socket channel. This will be populated by ServerSocketAdapter.accept. SocketChannelImpl result = new SocketChannelImpl(provider(), false); try { begin(); synchronized (acceptLock) { try { socket.implAccept(result); } catch (SocketTimeoutException e) { if (shouldThrowSocketTimeoutExceptionFromAccept(e)) { throw e; } // Otherwise, this is a non-blocking socket and there's nothing ready, so we'll // fall through and return null. } } } finally { end(result.socket().isConnected()); } return result.socket().isConnected() ? result : null; }
public ServerSocketChannel openServerSocketChannel() throws IOException { return new ServerSocketChannelImpl(this); }
@Override public Socket accept() throws IOException { if (!channelImpl.isBound) { throw new IllegalBlockingModeException(); } SocketChannel sc = channelImpl.accept(); if (sc == null) { throw new IllegalBlockingModeException(); } return sc.socket(); }
private boolean shouldThrowSocketTimeoutExceptionFromAccept(SocketTimeoutException e) { if (isBlocking()) { return true; } Throwable cause = e.getCause(); if (cause instanceof ErrnoException) { if (((ErrnoException) cause).errno == EAGAIN) { return false; } } return true; }
@Override public SocketChannel accept() throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (!isBound) { throw new NotYetBoundException(); } // Create an empty socket channel. This will be populated by ServerSocketAdapter.accept. SocketChannelImpl result = new SocketChannelImpl(provider(), false); try { begin(); synchronized (acceptLock) { try { socket.implAccept(result); } catch (SocketTimeoutException e) { if (shouldThrowSocketTimeoutExceptionFromAccept(e)) { throw e; } // Otherwise, this is a non-blocking socket and there's nothing ready, so we'll // fall through and return null. } } } finally { end(result.socket().isConnected()); } return result.socket().isConnected() ? result : null; }
public ServerSocketChannel openServerSocketChannel() throws IOException { return new ServerSocketChannelImpl(this); }