Package org.apache.mina.transport.nio

Examples of org.apache.mina.transport.nio.NioTcpClient.connect()


        client.setConnectTimeoutMillis(1000);

        ServerSocket server = new ServerSocket();
        try {
            server.bind(null);
            IoFuture<IoSession> cf = client.connect(new InetSocketAddress("localhost", server.getLocalPort()));
            Thread.sleep(5000);
            IoSession session = cf.get();
            System.err.println(session);
            Assert.fail();
        } catch (ExecutionException ex) {
View Full Code Here


        // now connect the clients

        List<IoFuture<IoSession>> cf = new ArrayList<IoFuture<IoSession>>();
        for (int i = 0; i < CLIENT_COUNT; i++) {
            cf.add(client.connect(new InetSocketAddress("localhost", port)));
        }

        Socket[] clientSockets = new Socket[CLIENT_COUNT];
        for (int i = 0; i < CLIENT_COUNT; i++) {
            clientSockets[i] = serverSocket.accept();
View Full Code Here

        NioTcpClient client = new NioTcpClient();
        client.setIoHandler(new AbstractIoHandler() {
        });
        for (int i = 0; i < CLIENT_COUNT; ++i) {
            client.connect(new InetSocketAddress(server.getServerSocketChannel().socket().getLocalPort())).get();
        }
        client.disconnect();
        assertTrue(closedLatch.await(WAIT_TIME, TimeUnit.MILLISECONDS));
    }
View Full Code Here

                LOG.info("session closed {}", session);
            }
        });

        try {
            IoFuture<IoSession> future = client.connect(new InetSocketAddress("localhost", 9999));

            try {
                IoSession session = future.get();
                LOG.info("session connected : {}", session);
            } catch (ExecutionException e) {
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.