Package org.apache.mina.transport.socket

Examples of org.apache.mina.transport.socket.SocketSessionConfig


                acceptor = new AprSocketAcceptor(NUM_IO_PROCESSORS);
            } else {
                LOG.info("NioSocketAcceptor is used for RemotePaging");
                acceptor = new NioSocketAcceptor(NUM_IO_PROCESSORS);
            }
            SocketSessionConfig config = acceptor.getSessionConfig();
            config.setReuseAddress(true);
            config.setReadBufferSize(1024);
            config.setSendBufferSize(SND_BUFSIZE);
            config.setBothIdleTime(SO_IDLETIME);
            config.setWriteTimeout(SO_WRITE_TIMEOUT);
            //config.setTcpNoDelay(true); // Disable Nagle's algorithm
            return acceptor;
        }
    }
View Full Code Here


    setSessionFactory(new SessionFactory() {
      @Override
      protected ServerSession createSession(final IoSession io)
          throws Exception {
        if (io.getConfig() instanceof SocketSessionConfig) {
          final SocketSessionConfig c = (SocketSessionConfig) io.getConfig();
          c.setKeepAlive(keepAlive);
        }

        final ServerSession s = (ServerSession) super.createSession(io);
        final int id = idGenerator.next();
        final SocketAddress peer = io.getRemoteAddress();
View Full Code Here

    // set acceptor props
    acceptor.setHandler(ioHandler);
    // requested maximum length of the queue of incoming connections
    acceptor.setBacklog(backlog);
    // get the current session config that would be used during create
    SocketSessionConfig sessionConf = acceptor.getSessionConfig();
    // reuse the addresses
    sessionConf.setReuseAddress(true);
    sessionConf.setTcpNoDelay(tcpNoDelay);
    sessionConf.setSendBufferSize(sendBufferSize);
    //
    sessionConf.setReceiveBufferSize(receiveBufferSize);
    sessionConf.setMaxReadBufferSize(receiveBufferSize);
    // sets the interval (seconds) between each throughput calculation, the default value is 3 seconds
    sessionConf.setThroughputCalculationInterval(thoughputCalcInterval);
    // set the reader idle time (seconds)
    sessionConf.setReaderIdleTime(readerIdleTime);
    sessionConf.setKeepAlive(keepAlive);
    // to prevent setting of the traffic class we expect a value of -1
    if (trafficClass == -1) {
      log.info("Traffic class modification is disabled");
    } else {
      // set the traffic class - http://docs.oracle.com/javase/6/docs/api/java/net/Socket.html#setTrafficClass(int)
      // IPTOS_LOWCOST (0x02)
      // IPTOS_RELIABILITY (0x04)
      // IPTOS_THROUGHPUT (0x08) *
      // IPTOS_LOWDELAY (0x10) *
      sessionConf.setTrafficClass(trafficClass);
    }
    // get info
    log.info("Send buffer size: {} recv buffer size: {} so linger: {} traffic class: {}", new Object[] { sessionConf.getSendBufferSize(), sessionConf.getReceiveBufferSize(),
        sessionConf.getSoLinger(), sessionConf.getTrafficClass() });
    // set reuse address on the socket acceptor as well
    acceptor.setReuseAddress(true);
    try {
      // loop through the addresses and bind
      Set<InetSocketAddress> socketAddresses = new HashSet<InetSocketAddress>();
View Full Code Here

  }

  /** {@inheritDoc} */
  @Override
  public void sessionOpened(IoSession session) throws Exception {
    SocketSessionConfig ssc = (SocketSessionConfig) session.getConfig();
    ssc.setTcpNoDelay(true);
    //ssc.setReceiveBufferSize(2048);
    //ssc.setSendBufferSize(2048);

    super.sessionOpened(session);

View Full Code Here

        // The logger, if needed. Commented atm
        //DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
        //chain.addLast("logger", new LoggingFilter());

        SocketSessionConfig scfg = acceptor.getSessionConfig();

        acceptor.bind(new InetSocketAddress(PORT));

        System.out.println("Server started...");
    }
View Full Code Here

     */
    public TcpClient() {
        connector = new NioSocketConnector();

        connector.setHandler(this);
        SocketSessionConfig dcfg = (SocketSessionConfig) connector.getSessionConfig();

        ConnectFuture connFuture = connector.connect(new InetSocketAddress("localhost", TcpServer.PORT));

        connFuture.awaitUninterruptibly();

View Full Code Here

    setSessionFactory(new SessionFactory() {
      @Override
      protected ServerSession createSession(final IoSession io)
          throws Exception {
        if (io.getConfig() instanceof SocketSessionConfig) {
          final SocketSessionConfig c = (SocketSessionConfig) io.getConfig();
          c.setKeepAlive(keepAlive);
        }

        final ServerSession s = (ServerSession) super.createSession(io);
        final int id = idGenerator.next();
        final SocketAddress peer = io.getRemoteAddress();
View Full Code Here

TOP

Related Classes of org.apache.mina.transport.socket.SocketSessionConfig

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.