• Minabased TCP server examples


    A very simple server-side example here.

    one acceptor plus one handler.

    public class MinaTimeServer
    {
    private static final int PORT = 9123;

    public static void main( String[] args ) throws IOException
    {
    IoAcceptor acceptor = new NioSocketAcceptor();

    /*
    acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
    acceptor.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new TextLineCodecFactory( Charset.forName( "UTF-8" ))));
    */

    acceptor.setHandler( new TimeServerHandler() );
    /*
    acceptor.getSessionConfig().setReadBufferSize( 2048 );
    acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, 10 );
    */
    acceptor.bind( new InetSocketAddress(PORT) );
    }
    }
    public class TimeServerHandler extends IoHandlerAdapter
    {
    /*
    @Override
    public void exceptionCaught( IoSession session, Throwable cause ) throws Exception
    {
    cause.printStackTrace();
    }
    */

    @Override
    public void messageReceived( IoSession session, Object message ) throws Exception
    {
    String str = message.toString();
    if( str.trim().equalsIgnoreCase("quit") ) {
    session.close();
    return;
    }

    Date date = new Date();
    session.write( date.toString() );
    System.out.println("Message written...");
    }

    /*
    @Override
    public void sessionIdle( IoSession session, IdleStatus status ) throws Exception
    {
    System.out.println( "IDLE " + session.getIdleCount( status ));
    }
    */
    }



  • 相关阅读:
    filebeat测试output连通性
    es分片数相关知识
    Elasticsearch的mapping讲解
    Kibana插件
    Kibana管理
    Kibana控制台(Dev Tools) Console
    Kibana仪表盘(Dashboard)详解
    Kibana可视化数据(Visualize)详解
    Kibana探索数据(Discover)详解
    Kibana使用仪表盘汇总数据(Dashboard)
  • 原文地址:https://www.cnblogs.com/alipayhutu/p/2316508.html
Copyright © 2020-2023  润新知