Package java.nio.channels

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


                addr = new InetSocketAddress(_bindAddress, 0);
                sch.socket().bind(addr);
            }

            addr = new InetSocketAddress(_host, _port);
            sch.connect(addr);
        } catch (IOException e) {
          _selector.close();
          throw e;
        }
View Full Code Here


                        SocketChannel socketChannel = SocketChannel.open();
                        socketChannel.configureBlocking(false);

                        InetSocketAddress address = new InetSocketAddress(host, port);

                        socketChannel.connect(address);

                        Session session = new Session(socketChannel, address, uri);
                        session.ops(java.nio.channels.SelectionKey.OP_CONNECT);
                        session.trace("client");
                        connections.put(session.uri, session);
View Full Code Here

                sch = SocketChannel.open();
                sch.configureBlocking(true);
                sch.socket().setSoTimeout(5000);

                InetSocketAddress addr = new InetSocketAddress(ipAddress, port);
                sch.connect(addr);
                return null;
            } catch (IOException e) {
                s_logger.info("Could not connect to " + ipAddress + " due to " + e.toString());
                if (e instanceof ConnectException) {
                    // if connection is refused because of VM is being started,
View Full Code Here

                        SocketChannel socketChannel = SocketChannel.open();
                        socketChannel.configureBlocking(false);

                        InetSocketAddress address = new InetSocketAddress(host, port);

                        socketChannel.connect(address);

                        Session session = new Session(socketChannel, address, uri);
                        session.ops(java.nio.channels.SelectionKey.OP_CONNECT);
                        session.trace("client");
                        connections.put(session.uri, session);
View Full Code Here

      throws IOException {
    // Create client SocketChannel
    SocketChannel channel = SocketChannel.open();
    channel.configureBlocking(true);

    channel.connect(immortalSocket.getAddress());

    sendInt(channel, -1);

    int id = readInt(channel);
View Full Code Here

          // We do this first operations in blocking mode.
          channel.configureBlocking(true);

          // We try to connect to the server.
          channel.connect(immortalSocket.getAddress());

          // Then we send the socket id.
          sendInt(channel, immortalSocket.getId());

          // We receive the number of packet the socket on the other
View Full Code Here

        socket.setSoTimeout(getMaxIoIdleTimeMs());
        socket.setTcpNoDelay(isSocketNoDelay());
        socket.setTrafficClass(getSocketTrafficClass());

        InetSocketAddress address = new InetSocketAddress(hostDomain, hostPort);
        result.connect(address);
        return result;
    }

    @Override
    public void doHandleInbound(Response response) {
View Full Code Here

        for (String host : hosts) {       
            SocketChannel channel = SocketChannel.open();
            channel.configureBlocking(false);
            channel.register(selector, SelectionKey.OP_CONNECT);
            SocketAddress addr = new InetSocketAddress(host, port);
            channel.connect(addr);
        }
        SocketChannel connectedChannel = null;

        connect:
        while (true) {
View Full Code Here

                ch.socket().bind( localAddress );
            }

            ch.configureBlocking( false );

            if( ch.connect( address ) )
            {
                SocketSessionImpl session = newSession( ch, handler, config );
                success = true;
                DefaultConnectFuture future = new DefaultConnectFuture();
                future.setSession( session );
View Full Code Here

                ch.socket().bind(localAddress);
            }

            ch.configureBlocking(false);

            if (ch.connect(address)) {
                DefaultConnectFuture future = new DefaultConnectFuture();
                newSession(ch, handler, config, future);
                success = true;
                return future;
            }
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.