Examples of NioSocketConnector


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

      Thread.sleep( 500 )
       
      this.client = new ServiceManagerClient( "client 1",
                             new MessageHandler(SystemEventListenerFactory.getSystemEventListener()) );
     
      NioSocketConnector connector = new NioSocketConnector();
      SocketAddress address = new InetSocketAddress( "127.0.0.1",
                                                     9123 );
      client.connect( connector,
                      address );   
     
View Full Code Here

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

      Thread.sleep( 500 )
       
      this.client = new ServiceManagerClient( "client 1",
                             new MessageHandler(SystemEventListenerFactory.getSystemEventListener()) );
     
      NioSocketConnector connector = new NioSocketConnector();
      SocketAddress address = new InetSocketAddress( "127.0.0.1",
                                                     9123 );
      client.connect( connector,
                      address );
    }
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

        }

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

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

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

     *
     * @throws Exception
     */
    public ProxyTelnetTestClient() throws Exception {
        // Create proxy connector.
        NioSocketConnector targetConnector = new NioSocketConnector(Runtime
                .getRuntime().availableProcessors() + 1);
        ProxyConnector connector = new ProxyConnector(targetConnector);

        /*
        // Example of socks v5 proxy use
        SocksProxyRequest req = new SocksProxyRequest(
                SocksProxyConstants.SOCKS_VERSION_5,
                SocksProxyConstants.ESTABLISH_TCPIP_STREAM, serverAddress, USER);
        req.setPassword(PWD);
        */

        HttpProxyRequest req = new HttpProxyRequest(serverAddress);
        HashMap<String, String> props = new HashMap<String, String>();
        props.put(HttpProxyConstants.USER_PROPERTY, USER);
        props.put(HttpProxyConstants.PWD_PROPERTY, PWD);
        req.setProperties(props);       

        ProxyIoSession proxyIoSession = new ProxyIoSession(proxyAddress, req);
        connector.setProxyIoSession(proxyIoSession);

        LineDelimiter delim = new LineDelimiter("\r\n");
        targetConnector.getFilterChain().addLast(
                "codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(Charset
                        .forName("UTF-8"), delim, delim)));

        connector.setHandler(new TelnetSessionHandler());
View Full Code Here

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

                            + " <proxy-hostname> <proxy-port> <url> <proxy-method> (<proxy-method> is OPTIONNAL)");
            return;
        }

        // Create proxy connector.
        NioSocketConnector socketConnector = new NioSocketConnector(Runtime
                .getRuntime().availableProcessors() + 1);

        ProxyConnector connector = new ProxyConnector(socketConnector);

        // Set connect timeout.
        connector.setConnectTimeoutMillis(5000);

        URL url = new URL(args[2]);
        int port = url.getPort() == -1 ? url.getDefaultPort() : url.getPort();

        ProxyRequest req = null;

        if (args.length == 4) {
            if ("SOCKS4".equals(args[3])) {
                req = new SocksProxyRequest(
                        SocksProxyConstants.SOCKS_VERSION_4,
                        SocksProxyConstants.ESTABLISH_TCPIP_STREAM,
                        new InetSocketAddress(url.getHost(), port), USER);
            } else if ("SOCKS4a".equals(args[3])) {
                req = new SocksProxyRequest(
                        SocksProxyConstants.ESTABLISH_TCPIP_STREAM, url
                                .getHost(), port, USER);
            } else if ("SOCKS5".equals(args[3])) {
                req = new SocksProxyRequest(
                        SocksProxyConstants.SOCKS_VERSION_5,
                        SocksProxyConstants.ESTABLISH_TCPIP_STREAM,
                        new InetSocketAddress(url.getHost(), port), USER);
                ((SocksProxyRequest) req).setPassword(PWD);
                ((SocksProxyRequest) req)
                        .setServiceKerberosName(Socks5GSSAPITestServer.SERVICE_NAME);
            } else {
                req = createHttpProxyRequest(args[2]);
            }
        } else {
            req = createHttpProxyRequest(args[2]);
        }

        ProxyIoSession proxyIoSession = new ProxyIoSession(
                new InetSocketAddress(args[0], Integer.parseInt(args[1])), req);

        // Tests modifying authentication order preferences. First algorithm in list available on server
        // will be used for authentication.
        List<HttpAuthenticationMethods> l = new ArrayList<HttpAuthenticationMethods>();
        l.add(HttpAuthenticationMethods.DIGEST);
        l.add(HttpAuthenticationMethods.BASIC);
        proxyIoSession.setPreferedOrder(l);

        connector.setProxyIoSession(proxyIoSession);

        socketConnector.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 5);

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

        // This command is sent when using a socks proxy to request a page from the web server.
        String cmd = "GET " + url.toExternalForm() + " HTTP/1.0"
View Full Code Here

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

        super(manager, handler);
    }


    protected IoConnector createConnector() {
        NioSocketConnector connector = new NioSocketConnector(getNioWorkers());
        if (sessionConfig != null) {
            connector.getSessionConfig().setAll(sessionConfig);
        }
        return connector;
    }
View Full Code Here

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

 
  public void init() {
    dispose();
   
    int processors = Runtime.getRuntime().availableProcessors();
    connector = new NioSocketConnector(processors*2);
    connector.getSessionConfig().setReuseAddress(true);
//    connector.getSessionConfig().setReaderIdleTime(30);
//    connector.getSessionConfig().setWriterIdleTime(30);
//    connector.getSessionConfig().setBothIdleTime(idleTime);
//    connector.getSessionConfig().setUseReadOperation(true);
 
View Full Code Here

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

    // Private -------------------------------------------------------

    private void keepAliveFilterForIdleStatus(IdleStatus status)
            throws Exception {
        NioSocketConnector connector = new NioSocketConnector();
        KeepAliveFilter filter = new KeepAliveFilter(new ClientFactory(),
                status, EXCEPTION, INTERVAL, TIMEOUT);
        filter.setForwardEvent(true);
        connector.getFilterChain().addLast("keep-alive", filter);

        final AtomicBoolean gotException = new AtomicBoolean(false);
        connector.setHandler(new IoHandlerAdapter() {
            @Override
            public void exceptionCaught(IoSession session, Throwable cause)
                    throws Exception {
                cause.printStackTrace();
                gotException.set(true);
            }

            @Override
            public void sessionIdle(IoSession session, IdleStatus status)
                    throws Exception {
                System.out.println("client idle:" + status);
            }
        });

        ConnectFuture future = connector.connect(
                new InetSocketAddress("127.0.0.1", port)).awaitUninterruptibly();
        IoSession session = future.getSession();
        assertNotNull(session);

        Thread.sleep((INTERVAL + TIMEOUT + 1) * 1000);

        assertFalse("got an exception on the client", gotException.get());

        session.close(true);
        connector.dispose();
    }
View Full Code Here

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

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

    public void testTCP() throws Exception {
        IoConnector connector = new NioSocketConnector();
        testConnector(connector);
    }
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.