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

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


        }
       
    /*
     * Bind the TCP port
     */
    m_tcpAcceptor = new NioSocketAcceptor();
    m_tcpAcceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new PokenetCodecFactory()));
    m_tcpAcceptor.setHandler(m_tcpProtocolHandler);
    try {
      m_tcpAcceptor.bind(new InetSocketAddress(7002));
      System.out.println("INFO: TCP acceptor started.");
View Full Code Here


        sshd.setShellFactory(new EchoShellFactory());
        sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
        sshd.setForwardingFilter(new BogusForwardingFilter());
        sshd.start();

        NioSocketAcceptor acceptor = new NioSocketAcceptor();
        acceptor.setHandler(new IoHandlerAdapter() {
            @Override
            public void messageReceived(IoSession session, Object message) throws Exception {
                IoBuffer recv = (IoBuffer) message;
                IoBuffer sent = IoBuffer.allocate(recv.remaining());
                sent.put(recv);
                sent.flip();
                session.write(sent);
            }
        });
        acceptor.setReuseAddress(true);
        acceptor.bind(new InetSocketAddress(echoPort));
        this.acceptor = acceptor;

    }
View Full Code Here

        sb.append("HTTP/1.1 200 OK").append('\n');
        sb.append("Content-Type: text/HTML").append('\n');
        sb.append("Content-Length: ").append(resp.length()).append('\n');
        sb.append('\n');
        sb.append(resp);
        NioSocketAcceptor acceptor = new NioSocketAcceptor();
        acceptor.setHandler(new IoHandlerAdapter() {
            @Override
            public void messageReceived(IoSession session, Object message) throws Exception {
                session.write(IoBuffer.wrap(sb.toString().getBytes()));
            }
        });
        acceptor.setReuseAddress(true);
        acceptor.bind(new InetSocketAddress(port));


        Session session = createSession();

        final int forwardedPort1 = getFreePort();
View Full Code Here

        }
        return sessions;
    }

    protected IoAcceptor createAcceptor() {
        return new NioSocketAcceptor(getNioWorkers());
    }
View Full Code Here

        return new NioSocketAcceptor(getNioWorkers());
    }

    protected void configure(IoAcceptor acceptor) {
        if (acceptor instanceof NioSocketAcceptor) {
            final NioSocketAcceptor nio = (NioSocketAcceptor) acceptor;
            nio.setReuseAddress(reuseAddress);
            nio.setBacklog(backlog);

            // MINA itself forces our socket receive buffer to 1024 bytes
            // by default, despite what the operating system defaults to.
            // This limits us to about 3 MB/s incoming data transfer.  By
            // forcing back to the operating system default we can get a
            // decent transfer rate again.
            //
            final Socket s = new Socket();
            try {
              try {
                  nio.getSessionConfig().setReceiveBufferSize(s.getReceiveBufferSize());
              } finally {
                  s.close();
              }
            } catch (IOException e) {
                log.warn("cannot adjust SO_RCVBUF back to system default", e);
View Full Code Here

        this.session = session;
    }

    public synchronized void initialize() {
        if (this.acceptor == null) {
            NioSocketAcceptor acceptor = session.getServerFactoryManager().getTcpipForwardingAcceptorFactory().createNioSocketAcceptor(session);
            acceptor.setHandler(this);
            acceptor.setReuseAddress(true);
            acceptor.getFilterChain().addLast("executor", new ExecutorFilter(EnumSet.complementOf(EnumSet.of(IoEventType.SESSION_CREATED)).toArray(new IoEventType[0])));
            this.acceptor = acceptor;
        }
    }
View Full Code Here

    /** The log. */
    private final Logger log = LoggerFactory.getLogger(getClass());

    public NioSocketAcceptor createNioSocketAcceptor(ServerSession s) {
        NioSocketAcceptor nio = new NioSocketAcceptor();
        nio.setReuseAddress(true);

        configureReceiveBufferSize(nio);

        return nio;
    }
View Full Code Here

    }

    public void start() throws IOException {
        running = true;

        acceptor = new NioSocketAcceptor();

        acceptor.getFilterChain().addLast( "logger",
                                           new LoggingFilter() );
        acceptor.getFilterChain().addLast( "codec",
                                           new ProtocolCodecFilter( new ObjectSerializationCodecFactory() ) );
View Full Code Here

    public MinaAcceptor(FactoryManager manager, org.apache.sshd.common.io.IoHandler handler) {
        super(manager, handler);
    }

    protected IoAcceptor createAcceptor() {
        NioSocketAcceptor acceptor = new NioSocketAcceptor(getNioWorkers());
        acceptor.setCloseOnDeactivation(false);
        acceptor.setReuseAddress(reuseAddress);
        acceptor.setBacklog(backlog);

        // MINA itself forces our socket receive buffer to 1024 bytes
        // by default, despite what the operating system defaults to.
        // This limits us to about 3 MB/s incoming data transfer.  By
        // forcing back to the operating system default we can get a
        // decent transfer rate again.
        //
        final Socket s = new Socket();
        try {
            try {
                acceptor.getSessionConfig().setReceiveBufferSize(s.getReceiveBufferSize());
            } finally {
                s.close();
            }
        } catch (IOException e) {
            log.warn("cannot adjust SO_RCVBUF back to system default", e);
        }
        if (sessionConfig != null) {
            acceptor.getSessionConfig().setAll(sessionConfig);
        }
        return acceptor;
    }
View Full Code Here

    private int port;
    private SocketAcceptor acceptor;

    @Before
    public void setUp() throws Exception {
        acceptor = new NioSocketAcceptor();
    }
View Full Code Here

TOP

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

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.