Package java.nio.channels

Examples of java.nio.channels.SocketChannel.configureBlocking()


                            }
                            SocketChannel chan = schan.accept();
                            if (chan == null) {
                                continue; /* cancel something ? */
                            }
                            chan.configureBlocking (false);
                            SelectionKey newkey = chan.register (selector, SelectionKey.OP_READ);
                            HttpConnection c = new HttpConnection ();
                            c.selectionKey = newkey;
                            c.setChannel (chan);
                            newkey.attach (c);
View Full Code Here


                                    boolean closed;
                                    SocketChannel chan = (SocketChannel)key.channel();
                                    HttpConnection conn = (HttpConnection)key.attachment();

                                    key.cancel();
                                    chan.configureBlocking (true);
                                    if (idleConnections.remove(conn)) {
                                        // was an idle connection so add it
                                        // to reqConnections set.
                                        requestStarted (conn);
                                    }
View Full Code Here

            final String message = "Connecting to " + socketAddress + ", timeout: " + timeout
                    + ", bind-any: " + connectionManager.ioService.isSocketBindAny();
            log(level, message);
        }
        try {
            socketChannel.configureBlocking(true);
            try {
                if (timeout > 0) {
                    socketChannel.socket().connect(socketAddress, timeout);
                } else {
                    socketChannel.connect(socketAddress);
View Full Code Here

                socket.setReceiveBufferSize(bufferSize);
                socketChannel.socket().connect(address.getInetSocketAddress(), 5000);
                SocketChannelWrapper socketChannelWrapper = socketChannelWrapperFactory.wrapSocketChannel(socketChannel, true);
                final ClientConnection clientConnection = new ClientConnection(ClientConnectionManagerImpl.this, inSelector,
                        outSelector, connectionIdGen.incrementAndGet(), socketChannelWrapper, executionService);
                socketChannel.configureBlocking(true);
                if (socketInterceptor != null) {
                    socketInterceptor.onConnect(socket);
                }
                authenticator.auth(clientConnection);
                socketChannel.configureBlocking(isBlock);
View Full Code Here

                socketChannel.configureBlocking(true);
                if (socketInterceptor != null) {
                    socketInterceptor.onConnect(socket);
                }
                authenticator.auth(clientConnection);
                socketChannel.configureBlocking(isBlock);
                socket.setSoTimeout(0);
                if (!isBlock) {
                    clientConnection.getReadHandler().register();
                }
                return clientConnection;
View Full Code Here

    public static SocketChannel openBlockingChannel(InetSocketAddress addr,
            boolean tcpNoDelay, int timeout) throws IOException {
        SocketChannel channel = SocketChannel.open();
        Socket socket = channel.socket();
        channel.configureBlocking(true);
        /* Disable Nagle, the client only sends short messages. */
        socket.setTcpNoDelay(tcpNoDelay);
        socket.setSoTimeout(timeout);
        socket.connect(addr);
        return channel;
View Full Code Here

        Socket socket = channel.socket();
        /*
         * Note that soTimeout is not set since it's a blocking channel and
         * setSoTimeout has no effect on a blocking nio channel.
         */
        channel.configureBlocking(true);

        /*
         * Push responses out rapidly, they are small (heart beat or commit
         * response) and need timely delivery to the master.
         */
 
View Full Code Here

                }

                if (service.simulateIOException()) {
                    throw new IOException("Simulated test IO exception");
                }
                channel.configureBlocking(blocking);
                socket = channel.socket();
                socket.setSoTimeout(soTimeout);
                return channel;
            } catch (IOException e) {
                LoggerUtils.logMsg(logger, repImpl, formatter, Level.WARNING,
View Full Code Here

            socketChannel = serverChannel.accept();
            if (!processAcceptRequests) {
                closeChannel(socketChannel);
                return;
            }
            socketChannel.configureBlocking(false);
            socketChannel.register
                (selector,
                 SelectionKey.OP_READ,
                 ByteBuffer.allocate(INITIAL_BUFFER_SIZE));
        } catch (IOException e) {
View Full Code Here

                        {
                            SocketChannel channel = acceptChannel(key);
                            if (channel==null)
                                continue;

                            channel.configureBlocking(false);

                            // TODO make it reluctant to leave 0
                            _nextSet=++_nextSet%_selectSet.length;

                            // Is this for this selectset
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.