Package org.apache.mina.transport.nio

Examples of org.apache.mina.transport.nio.NioTcpServer.bind()


        NioTcpServer server = new NioTcpServer();

        server.setReuseAddress(true);
        server.getSessionConfig().setSslContext(createSSLContext());
        server.setIoHandler(new TestHandler());
        server.bind(new InetSocketAddress(0));
        return server.getServerSocketChannel().socket().getLocalPort();
    }

    /**
     * Starts a client which will connect twice using SSL
View Full Code Here


                if (receivedSize == messageSize) {
                    counter.countDown();
                }
            }
        });
        server.bind(new InetSocketAddress(0));
        int port = server.getServerSocketChannel().socket().getLocalPort();

        /*
         * Client
         */
 
View Full Code Here

    public void generate_all_kind_of_server_event() throws IOException, InterruptedException {
        final NioTcpServer server = new NioTcpServer();
        server.setFilters();
        server.getSessionConfig().setIdleTimeInMillis(IdleStatus.READ_IDLE, 1000);
        server.setIoHandler(new Handler());
        server.bind(0);

        // warm up
        Thread.sleep(100);

        final int port = server.getServerSocketChannel().socket().getLocalPort();
View Full Code Here

    public void generateAllKindOfServerEventOneSelector() throws IOException, InterruptedException {
        SelectorLoopPool selectorLoopPool = new FixedSelectorLoopPool("Server", 1);
        final NioTcpServer server = new NioTcpServer(selectorLoopPool.getSelectorLoop(), selectorLoopPool, null);
        server.setFilters();
        server.setIoHandler(new Handler());
        server.bind(0);

        // warm up
        Thread.sleep(100);

        final int port = server.getServerSocketChannel().socket().getLocalPort();
View Full Code Here

    @Test
    public void generate_all_kind_of_server_event() throws IOException, InterruptedException {
        final NioTcpServer server = new NioTcpServer();
        server.setFilters(new MyCodec(), new Handler());
        server.bind(0);
        // warm up
        Thread.sleep(100);

        long t0 = System.currentTimeMillis();
        final int port = server.getServerSocketChannel().socket().getLocalPort();
View Full Code Here

    @Test
    public void generateAllKindOfServerEventOneSelector() throws IOException, InterruptedException {
        SelectorLoopPool selectorLoopPool = new FixedSelectorLoopPool("Server", 1);
        final NioTcpServer server = new NioTcpServer(selectorLoopPool.getSelectorLoop(), selectorLoopPool, null);
        server.setFilters(new MyCodec(), new Handler());
        server.bind(0);
        // warm up
        Thread.sleep(100);

        long t0 = System.currentTimeMillis();
        final int port = server.getServerSocketChannel().socket().getLocalPort();
View Full Code Here

        // 3 seconds idle time
        server.getSessionConfig().setIdleTimeInMillis(IdleStatus.READ_IDLE, 2000);

        // start the server
        server.bind(new InetSocketAddress(0));

        final int boundPort = server.getServerSocketChannel().socket().getLocalPort();
        server.setFilters(new IdleHandler(idleLatch));

        // fire the clients and let them idle
View Full Code Here

    public void checkSessionsAreClosedWhenClientIsDisconnected() throws IOException, InterruptedException,
            ExecutionException {

        NioTcpServer server = new NioTcpServer();
        server.setIoHandler(new Handler());
        server.bind(0);

        NioTcpClient client = new NioTcpClient();
        client.setIoHandler(new AbstractIoHandler() {
        });
        for (int i = 0; i < CLIENT_COUNT; ++i) {
View Full Code Here

                }
            }
        });
        try {
            final SocketAddress address = new InetSocketAddress(9999);
            acceptor.bind(address);
            LOG.debug("Running the server for 25 sec");
            Thread.sleep(25000);
            LOG.debug("Unbinding the TCP port");
            acceptor.unbind();
        } catch (final InterruptedException e) {
View Full Code Here

        httpServer.getSessionConfig().setTcpNoDelay(true);

        // Make it use https, injecting a default SSLContext instance
        httpServer.getSessionConfig().setSslContext(BogusSslContextFactory.getInstance(true));

        httpServer.bind(new InetSocketAddress(8080));

        // run for 20 seconds
        Thread.sleep(20000);
        httpServer.unbind();
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.