TCPNIOServerConnection obtainServerNIOConnection(final ServerSocketChannel channel) { final TCPNIOServerConnection connection = new TCPNIOServerConnection(this, channel); configureNIOConnection(connection); return connection; }
/** * Accept a {@link Connection}. Could be used only in standalone mode. * See {@link Connection#configureStandalone(boolean)}. * * @return {@link Future} * @throws java.io.IOException */ public GrizzlyFuture<Connection> accept() throws IOException { if (!isStandalone()) { throw new IllegalStateException("Accept could be used in standalone mode only"); } final GrizzlyFuture<Connection> future = acceptAsync(); if (isBlocking()) { try { future.get(); } catch (Exception ignored) { } } return future; }
if (!isStandalone()) { final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel == null) { return; configureAcceptedChannel(acceptedChannel); acceptedConnection = createClientConnection(acceptedChannel); notifyProbesAccept(this, acceptedConnection); registerAcceptedChannel(acceptedConnection, defaultCompletionHandler, SelectionKey.OP_READ); } else { synchronized (acceptSync) { if (acceptListener == null) { TCPNIOServerConnection.this.disableIOEvent( IOEvent.SERVER_ACCEPT); return; final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel == null) { return; configureAcceptedChannel(acceptedChannel); acceptedConnection = createClientConnection(acceptedChannel); notifyProbesAccept(this, acceptedConnection); registerAcceptedChannel(acceptedConnection,
/** * Asynchronously accept a {@link Connection} * * @return {@link Future} * @throws java.io.IOException */ protected GrizzlyFuture<Connection> acceptAsync() throws IOException { if (!isOpen()) { throw new IOException("Connection is closed"); } synchronized (acceptSync) { final FutureImpl<Connection> future = SafeFutureImpl.create(); final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel != null) { configureAcceptedChannel(acceptedChannel); final TCPNIOConnection clientConnection = createClientConnection(acceptedChannel); registerAcceptedChannel(clientConnection, new RegisterAcceptedChannelCompletionHandler(future), 0); } else { acceptListener = future; enableIOEvent(IOEvent.SERVER_ACCEPT); } return future; } }
serverConnection.setProcessor(getProcessor()); serverConnection.setProcessorSelector(getProcessorSelector()); tcpTransport.serverConnections.add(serverConnection); serverConnection.resetProperties(); tcpTransport.serverConnections.remove(serverConnection); serverConnection.closeSilently(); } else { try {
port = ((InetSocketAddress) serverConnection.getLocalAddress()).getPort();
private SocketChannel doAccept() throws IOException { if (!DISABLE_INTERRUPT_CLEAR && Thread.currentThread().isInterrupted()) { Thread.interrupted(); } return ((ServerSocketChannel) getChannel()).accept(); }
/** * Asynchronously accept a {@link Connection} * * @return {@link Future} * @throws java.io.IOException */ protected GrizzlyFuture<Connection> acceptAsync() throws IOException { if (!isOpen()) { throw new IOException("Connection is closed"); } synchronized (acceptSync) { final FutureImpl<Connection> future = SafeFutureImpl.create(); final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel != null) { configureAcceptedChannel(acceptedChannel); final TCPNIOConnection clientConnection = createClientConnection(acceptedChannel); registerAcceptedChannel(clientConnection, new RegisterAcceptedChannelCompletionHandler(future), 0); } else { acceptListener = future; enableIOEvent(IOEvent.SERVER_ACCEPT); } return future; } }
serverConnection.setProcessor(getProcessor()); serverConnection.setProcessorSelector(getProcessorSelector()); tcpTransport.serverConnections.add(serverConnection); serverConnection.resetProperties(); tcpTransport.serverConnections.remove(serverConnection); serverConnection.closeSilently(); } else { try {
port = ((InetSocketAddress) serverConnection.getLocalAddress()).getPort();
private SocketChannel doAccept() throws IOException { if (!DISABLE_INTERRUPT_CLEAR && Thread.currentThread().isInterrupted()) { Thread.interrupted(); } return ((ServerSocketChannel) getChannel()).accept(); }
if (!isStandalone()) { final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel == null) { return; configureAcceptedChannel(acceptedChannel); acceptedConnection = createClientConnection(acceptedChannel); notifyProbesAccept(this, acceptedConnection); registerAcceptedChannel(acceptedConnection, defaultCompletionHandler, SelectionKey.OP_READ); } else { synchronized (acceptSync) { if (acceptListener == null) { TCPNIOServerConnection.this.disableIOEvent( IOEvent.SERVER_ACCEPT); return; final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel == null) { return; configureAcceptedChannel(acceptedChannel); acceptedConnection = createClientConnection(acceptedChannel); notifyProbesAccept(this, acceptedConnection); registerAcceptedChannel(acceptedConnection,
/** * Asynchronously accept a {@link Connection} * * @return {@link Future} * @throws java.io.IOException */ protected GrizzlyFuture<Connection> acceptAsync() throws IOException { if (!isOpen()) { throw new IOException("Connection is closed"); } synchronized (acceptSync) { final FutureImpl<Connection> future = SafeFutureImpl.create(); final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel != null) { configureAcceptedChannel(acceptedChannel); final TCPNIOConnection clientConnection = createClientConnection(acceptedChannel); registerAcceptedChannel(clientConnection, new RegisterAcceptedChannelCompletionHandler(future), 0); } else { acceptListener = future; enableIOEvent(IOEvent.SERVER_ACCEPT); } return future; } }
serverConnection.setProcessor(getProcessor()); serverConnection.setProcessorSelector(getProcessorSelector()); tcpTransport.serverConnections.add(serverConnection); serverConnection.resetProperties(); tcpTransport.serverConnections.remove(serverConnection); serverConnection.closeSilently(); } else { try {
/** * Accept a {@link Connection}. Could be used only in standalone mode. * See {@link Connection#configureStandalone(boolean)}. * * @return {@link Future} * @throws java.io.IOException */ public GrizzlyFuture<Connection> accept() throws IOException { if (!isStandalone()) { throw new IllegalStateException("Accept could be used in standalone mode only"); } final GrizzlyFuture<Connection> future = acceptAsync(); if (isBlocking()) { try { future.get(); } catch (Exception ignored) { } } return future; }
port = ((InetSocketAddress) serverConnection.getLocalAddress()).getPort();
TCPNIOServerConnection obtainServerNIOConnection(final ServerSocketChannel channel) { final TCPNIOServerConnection connection = new TCPNIOServerConnection(this, channel); configureNIOConnection(connection); return connection; }
private SocketChannel doAccept() throws IOException { if (!DISABLE_INTERRUPT_CLEAR && Thread.currentThread().isInterrupted()) { Thread.interrupted(); } return ((ServerSocketChannel) getChannel()).accept(); }
if (!isStandalone()) { final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel == null) { return; configureAcceptedChannel(acceptedChannel); acceptedConnection = createClientConnection(acceptedChannel); notifyProbesAccept(this, acceptedConnection); registerAcceptedChannel(acceptedConnection, defaultCompletionHandler, SelectionKey.OP_READ); } else { synchronized (acceptSync) { if (acceptListener == null) { TCPNIOServerConnection.this.disableIOEvent( IOEvent.SERVER_ACCEPT); return; final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel == null) { return; configureAcceptedChannel(acceptedChannel); acceptedConnection = createClientConnection(acceptedChannel); notifyProbesAccept(this, acceptedConnection); registerAcceptedChannel(acceptedConnection,
/** * Asynchronously accept a {@link Connection} * * @return {@link Future} * @throws java.io.IOException */ protected GrizzlyFuture<Connection> acceptAsync() throws IOException { if (!isOpen()) { throw new IOException("Connection is closed"); } synchronized (acceptSync) { final FutureImpl<Connection> future = SafeFutureImpl.create(); final SocketChannel acceptedChannel = doAccept(); if (acceptedChannel != null) { configureAcceptedChannel(acceptedChannel); final TCPNIOConnection clientConnection = createClientConnection(acceptedChannel); registerAcceptedChannel(clientConnection, new RegisterAcceptedChannelCompletionHandler(future), 0); } else { acceptListener = future; enableIOEvent(IOEvent.SERVER_ACCEPT); } return future; } }