Package org.apache.mina.core.future

Examples of org.apache.mina.core.future.ConnectFuture.awaitUninterruptibly()


        // Connect to the server.
        VmPipeConnector connector = new VmPipeConnector();
        connector.setHandler(new TennisPlayer());
        ConnectFuture future = connector.connect(address);
        future.awaitUninterruptibly();
        IoSession session = future.getSession();

        // Send the first ping message
        session.write(new TennisBall(10));
View Full Code Here


        connector.setHandler(new NetCatProtocolHandler());
        ConnectFuture cf = connector.connect(
                new InetSocketAddress(args[0], Integer.parseInt(args[1])));

        // Wait for the connection attempt to be finished.
        cf.awaitUninterruptibly();
        cf.getSession().getCloseFuture().awaitUninterruptibly();
       
        connector.dispose();
    }
}
View Full Code Here

        IoSession session;
        for (;;) {
            try {
                ConnectFuture future = connector.connect(new InetSocketAddress(
                        HOSTNAME, PORT));
                future.awaitUninterruptibly();
                session = future.getSession();
                break;
            } catch (RuntimeIoException e) {
                System.err.println("Failed to connect.");
                e.printStackTrace();
View Full Code Here

                    buf.append("X");
                }
            });
            ConnectFuture future = connector.connect(new InetSocketAddress(
                    "localhost", port));
            future.awaitUninterruptibly();
            buf.append("3");
            future.getSession().close();
            // sessionCreated() will fire before the connect future completes
            // but sessionOpened() may not
            Assert.assertTrue(Pattern.matches("12?32?", buf.toString()));
View Full Code Here

        });
       
        try {
            ConnectFuture future = connector.connect(new InetSocketAddress(
                    "localhost", port));
            future.awaitUninterruptibly();
            buf.append("1");
            try {
                future.getSession().close();
                fail();
            } catch (RuntimeIoException e) {
View Full Code Here

            throws Exception {
        IoSession session = null;
        if (!useLocalAddress) {
            ConnectFuture future = connector.connect(new InetSocketAddress(
                    "127.0.0.1", port));
            future.awaitUninterruptibly();
            session = future.getSession();
        } else {
            int clientPort = port;
            for (int i = 0; i < 65536; i++) {
                clientPort = AvailablePortFinder
View Full Code Here

                        .getNextAvailable(clientPort + 1);
                try {
                    ConnectFuture future = connector.connect(
                            new InetSocketAddress("127.0.0.1", port),
                            new InetSocketAddress(clientPort));
                    future.awaitUninterruptibly();
                    session = future.getSession();
                    break;
                } catch (RuntimeIoException e) {
                    // Try again until we succeed to bind.
                }
View Full Code Here

        log.debug("About to connect to the server...");
        ConnectFuture connFuture = connector.connect(new InetSocketAddress(
                "localhost", MemoryMonitor.PORT));

        log.debug("About to wait.");
        connFuture.awaitUninterruptibly();

        log.debug("Adding a future listener.");
        connFuture.addListener(new IoFutureListener<ConnectFuture>() {
            public void operationComplete(ConnectFuture future) {
                if (future.isConnected()) {
View Full Code Here

 
  public IoSession connect() {
    synchronized (connector) {
      try {
        ConnectFuture future = connector.connect(new InetSocketAddress(host, port));
        future.awaitUninterruptibly();
        return future.getSession();
      } catch (RuntimeIoException e) {
        e.printStackTrace();
        return null;
      }
View Full Code Here

        if(logger.isTraceEnabled()){
            logger.trace(" ### Connecting with "+address.getHostName()+":"+address.getPort());
        }                                             
        ConnectFuture future1 = this.connector.connect( address );
        future1.awaitUninterruptibly();
        if ( !future1.isConnected() ) {
            throw new IllegalStateException( "Unnable to connect to " + address );
        }
        IoSession session = future1.getSession();
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.