Package org.apache.mina.transport.socket.nio

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


        ((SocketAcceptorConfig) acceptor.getDefaultConfig())
                .setReuseAddress(true);
        SocketAddress address = new InetSocketAddress("localhost",
                AvailablePortFinder.getNextAvailable());

        IoConnector connector = new SocketConnector();

        FixedRandomInputStream stream = new FixedRandomInputStream(
                4 * 1024 * 1024);

        SenderHandler sender = new SenderHandler(stream);
        ReceiverHandler receiver = new ReceiverHandler(stream.size);

        acceptor.bind(address, sender);

        synchronized (sender.lock) {
            synchronized (receiver.lock) {
                connector.connect(address, receiver);

                sender.lock.wait();
                receiver.lock.wait();
            }
        }
View Full Code Here


        IoAcceptor acceptor = new SocketAcceptor();
        ((SocketAcceptorConfig) acceptor.getDefaultConfig())
                .setReuseAddress(true);

        // Create TCP/IP connector.
        IoConnector connector = new SocketConnector();

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

        ClientToProxyIoHandler handler = new ClientToProxyIoHandler(
                new ServerToProxyIoHandler(), connector, new InetSocketAddress(
                        args[1], Integer.parseInt(args[2])));
View Full Code Here

            System.out.println(Main.class.getName() + " <hostname> <port>");
            return;
        }

        // Create TCP/IP connector.
        SocketConnector connector = new SocketConnector();

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

        // Start communication.
        connector.connect(new InetSocketAddress(args[0], Integer
                .parseInt(args[1])), new NetCatProtocolHandler());
    }
View Full Code Here

                .getInstance(false));
        connectorSSLFilter.setUseClientMode(true); // set client mode
    }

    public void testTCP() throws Exception {
        IoConnector connector = new SocketConnector();
        testConnector(connector);
    }
View Full Code Here

    }

    public void testTCPWithSSL() throws Exception {
        useSSL = true;
        // Create a connector
        IoConnector connector = new SocketConnector();

        // Add an SSL filter to connector
        connector.getDefaultConfig().getFilterChain().addLast("SSL",
                connectorSSLFilter);
        testConnector(connector);
    }
View Full Code Here

    private SocketConnector connector;

    public SwingChatClient() {
        super("Chat Client based on Apache MINA");

        connector = new SocketConnector();

        loginButton = new JButton(new LoginAction());
        loginButton.setText("Connect");
        quitButton = new JButton(new LogoutAction());
        quitButton.setText("Disconnect");
View Full Code Here

        int[] values = new int[args.length];
        for (int i = 0; i < args.length; i++) {
            values[i] = Integer.parseInt(args[i]);
        }

        SocketConnector connector = new SocketConnector();

        // Change the worker timeout to 1 second to make the I/O thread quit soon
        // when there's no connection to manage.
        connector.setWorkerTimeout(1);

        // Configure the service.
        SocketConnectorConfig cfg = new SocketConnectorConfig();
        cfg.setConnectTimeout(CONNECT_TIMEOUT);
        if (USE_CUSTOM_CODEC) {
            cfg.getFilterChain().addLast(
                    "codec",
                    new ProtocolCodecFilter(
                            new SumUpProtocolCodecFactory(false)));
        } else {
            cfg.getFilterChain().addLast(
                    "codec",
                    new ProtocolCodecFilter(
                            new ObjectSerializationCodecFactory()));
        }
        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;
View Full Code Here

        {
            _socketConnector = new MultiThreadSocketConnector(1, new QpidThreadExecutor());
        }
        else
        {
            _socketConnector = new SocketConnector(1, new QpidThreadExecutor()); // non-blocking
                                                                                 // connector
        }

        org.apache.mina.common.ByteBuffer.setUseDirectBuffers(Boolean.getBoolean("amqj.enableDirectBuffers"));
        // the MINA default is currently to use the pooled allocator although this may change in future
View Full Code Here

    }

    protected MinaEndpoint createSocketEndpoint(String uri, URI connectUri, Map parameters) {
        IoAcceptor acceptor = new SocketAcceptor();
        SocketAddress address = new InetSocketAddress(connectUri.getHost(), connectUri.getPort());
        IoConnector connector = new SocketConnector();

        // TODO customize the config via URI
        SocketConnectorConfig config = new SocketConnectorConfig();
        configureCodecFactory(config, parameters);
        return new MinaEndpoint(uri, this, address, acceptor, connector, config);
View Full Code Here

      }
    }
  }
 
  private void doConnect() {
    SocketConnector connector = new SocketConnector();
    SocketConnectorConfig config = new SocketConnectorConfig();
    SocketSessionConfig sessionConf =
      (SocketSessionConfig) config.getSessionConfig();
    sessionConf.setTcpNoDelay(true);
    while (true) {
      ConnectFuture future = connector.connect(new InetSocketAddress(server, port), ioHandlerWrapper, config);
      future.join();
      if (future.isConnected()) {
        break;
      }
      try {
View Full Code Here

TOP

Related Classes of org.apache.mina.transport.socket.nio.SocketConnector

Copyright © 2018 www.massapicom. 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.