Examples of ConnectFuture


Examples of com.yz.net.expand.ConnectFuture

          try {
            handleConnect(session);
          } catch (IOException e) {
            //TODO:记录下异常
            e.printStackTrace();
            ConnectFuture future =  (ConnectFuture) ((ClientIoSession) session).getConnectFuture();
            future.setComplete(e);          //设置完成
            session.close();
          }
        }
       
        if(sk.isValid() && sk.isReadable()) {
View Full Code Here

Examples of com.yz.net.expand.ConnectFuture

      session.setReadControl(true);         //打开读
      session.setWriteControl(true);        //打开与
      session.setConnectControl(false);     //关闭
      this.onRegisterSession(session);      //session添加到管理器中

      ConnectFuture future =  (ConnectFuture) ((ClientIoSession) session).getConnectFuture();
      future.setComplete(null);                 //设置完成
    }
  }
View Full Code Here

Examples of org.apache.mina.common.ConnectFuture

        // Set connect timeout.
        ((IoConnectorConfig) connector.getDefaultConfig())
                .setConnectTimeout(15);

        // Start communication.
        ConnectFuture cf = connector.connect(new InetSocketAddress(
                args[0], Integer.parseInt(args[1])), new NetCatProtocolHandler());
       
        // Wait for the connection attempt to be finished.
        cf.join();
        cf.getSession();
    }
View Full Code Here

Examples of org.apache.mina.common.ConnectFuture

        // Set connect timeout.
        ((IoConnectorConfig) connector.getDefaultConfig())
                .setConnectTimeout(15);

        // Start communication.
        ConnectFuture cf = connector.connect(new InetSocketAddress(
                args[0], Integer.parseInt(args[1])), new NetCatProtocolHandler());
       
        // Wait for the connection attempt to be finished.
        cf.join();
        cf.getSession();
    }
View Full Code Here

Examples of org.apache.mina.common.ConnectFuture

        cfg.getFilterChain().addLast("logger", new LoggingFilter());

        IoSession session;
        for (;;) {
            try {
                ConnectFuture future = connector.connect(new InetSocketAddress(
                        HOSTNAME, PORT), new ClientSessionHandler(values), cfg);

                future.join();
                session = future.getSession();
                break;
            } catch (RuntimeIOException e) {
                System.err.println("Failed to connect.");
                e.printStackTrace();
                Thread.sleep(5000);
View Full Code Here

Examples of org.apache.mina.common.ConnectFuture

        // Set up server
        acceptor.bind(address, new TennisPlayer());

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

        // Send the first ping message
        session.write(new TennisBall(10));

        // Wait until the match ends.
View Full Code Here

Examples of org.apache.mina.common.ConnectFuture

                throw e;
            }
            connListener = new ConnectorConnListner(listener);
        }
        logger.log(Level.FINE, "connecting to {0}", endpoint);
        ConnectFuture future =
      connector.connect(endpoint.getAddress(), connListener);
  synchronized (this) {
      connectFuture = future;
  }
    }
View Full Code Here

Examples of org.apache.mina.common.ConnectFuture

     * {@inheritDoc}
     */
    public boolean waitForConnect(long timeout)
  throws IOException, InterruptedException
    {
  ConnectFuture future;
  synchronized (this) {
      future = connectFuture;
  }
  if (future == null) {
      throw new IllegalStateException("No connect attempt in progress");
  }
        if (!future.isConnected()) {
      future.join(timeout);
  }

  boolean ready = future.isReady();
  if (ready) {
      try {
    future.getSession();
      } catch (RuntimeIOException e) {
    Throwable t = e.getCause();
    if (t instanceof IOException) {
        throw (IOException) t;
    }
View Full Code Here

Examples of org.apache.mina.common.ConnectFuture

            public void messageReceived(IoSession ioSession, Object object) throws Exception {
                super.messageReceived(ioSession, object);
                /** TODO */
            }
        };
        ConnectFuture future = connector.connect(address, ioHandler, endpoint.getConfig());
        future.join();
        session = future.getSession();
    }
View Full Code Here

Examples of org.apache.mina.common.ConnectFuture

        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating connector to address: " + address + " using connector: " + connector + " timeout: " + timeout + " millis.");
        }
        IoHandler ioHandler = new ResponseHandler(endpoint);
        // connect and wait until the connection is established
        ConnectFuture future = connector.connect(address, ioHandler, endpoint.getConnectorConfig());
        future.join();
        session = future.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.