Examples of NioSocketConnector


Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

        this.connector.setHandler( this.handler );
        return connect();
    }

  public boolean connect(String address, int port) {
    this.connector = new NioSocketConnector();
        this.address = new InetSocketAddress( address, port );
        this.connector.setHandler( this.handler );
        return connect();
  }
View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

            throw new IllegalStateException(
                    "Already connected. Disconnect first.");
        }

        if (this.connector==null) {
          this.connector = new NioSocketConnector();
        }
       
        if (this.address==null) {
          this.address = new InetSocketAddress( "127.0.0.1", 9123);
        }
View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

   * 以一个执行器构造
   * @param executor    线程执行器
   */
  public MinaTransferFactory(Executor executor)
  {
    this.connector = new NioSocketConnector(new  NioProcessor(executor));
    this.connector.setHandler(new MinaNioHandler());
  }
View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

      this.sessionOpenId = sessionOpenId;
     
      log.debug("UDPClient::UDPClient "+this.sessionOpenId);
      log.debug("Created a datagram connector");
      //connector = new NioDatagramConnector();
      connector = new NioSocketConnector();
     
//      connector.getSessionConfig().setMinReadBufferSize(8192);
//      connector.getSessionConfig().setMaxReadBufferSize(8192);
//      connector.getSessionConfig().setReadBufferSize(8192);
//      connector.getSessionConfig().setReceiveBufferSize(8192);
View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

    acceptor.getSessionConfig().setReadBufferSize( 2048 );
    acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, 10 );
    acceptor.bind( new InetSocketAddress(PORT) );
    System.out.println("Server running ...");

    final NioSocketConnector connector = new NioSocketConnector();

    // Set connect timeout.
    connector.setConnectTimeoutMillis(30 * 1000L);

    connector.setHandler(new ClientHandler());
    connector.getFilterChain().addLast( "logger", new LoggingFilter() );
    connector.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new TextLineCodecFactory( Charset.forName( "UTF-8" ))));

    // Start communication.
    ConnectFuture cf = connector.connect(new InetSocketAddress("localhost", 9123));
    cf.awaitUninterruptibly();

    IoSession session = cf.getSession();

    // send a message
    session.write("Hello World!\r");

    // wait until response is received
    CountDownLatch latch = (CountDownLatch) session.getAttribute("latch");
    latch.await();

    // close the session
    CloseFuture closeFuture = session.close(false);

    System.out.println("session.close called");
    //Thread.sleep(5);

    // wait for session close and then dispose the connector
    closeFuture.addListener(new IoFutureListener<IoFuture>() {

      public void operationComplete(IoFuture future) {
        System.out.println("managed session count=" + connector.getManagedSessionCount());
        System.out.println("Disposing connector ...");
        connector.dispose(true);
        System.out.println("Disposing connector ... *finished*");

      }
    });

View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

        }

        // Create the connector if needed
        if ( connector == null )
        {
            connector = new NioSocketConnector();

            // Add the codec to the chain
            connector.getFilterChain().addLast( "ldapCodec", ldapProtocolFilter );

            // If we use SSL, we have to add the SslFilter to the chain
View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

    private List<MessageFilter> filters = new ArrayList<MessageFilter>();
    private NotificationListener notificationListener;

    public MTalkConnector(NotificationListener notificationListener) {
  this.notificationListener = notificationListener;
  connector = new NioSocketConnector();
  connector.setHandler(this);
  connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new GSFCodecFactory()));
  connector.getFilterChain().addFirst("sslfilter", getSSLFilter());
    }
View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

    public void setServerKeyVerifier(ServerKeyVerifier serverKeyVerifier) {
        this.serverKeyVerifier = serverKeyVerifier;
    }

    public void start() {
        connector = new NioSocketConnector();

        SessionFactory handler = sessionFactory;
        if (handler == null) {
            handler = new SessionFactory();
        }
View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

        // Create the connector if needed
        if ( connector == null )
        {
            // Use only one thead inside the connector
            connector = new NioSocketConnector( 1 );

            // Add the codec to the chain
            connector.getFilterChain().addLast( "ldapCodec", ldapProtocolFilter );

            // If we use SSL, we have to add the SslFilter to the chain
View Full Code Here

Examples of org.apache.mina.transport.socket.nio.NioSocketConnector

        List<IoFilter> filters = configuration.getFilters();

        address = new InetSocketAddress(configuration.getHost(), configuration.getPort());

        final int processorCount = Runtime.getRuntime().availableProcessors() + 1;
        connector = new NioSocketConnector(processorCount);

        // connector config
        connectorConfig = connector.getSessionConfig();

        if (configuration.isOrderedThreadPoolExecutor()) {
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.