基于 Java NIO 的异步 IO 框架 BaseIO

码农软件 · 软件分类 · 高性能网络开发库 · 2019-08-31 12:59:26

软件介绍

BaseIO是基于java nio开发的一款可快速构建网络通讯项目的异步IO框架,其以简单易用的API和优良的性能深受开发者喜爱。

项目特色

  • 支持协议扩展,已知的扩展协议有:

    • Redis协议(仅作测试),示例:详见 {baseio-test}

    • LineBased协议(基于换行符的消息分割),示例:详见 {baseio-test}

    • FixedLength协议(固定长度报文头),支持传输文本和二进制数据

    • HTTP1.1协议(lite),示例: https://www.generallycloud.com/

    • WebSocket协议,示例: https://www.generallycloud.com/web-socket/chat/index.html

    • Protobase(自定义协议),支持传输文本和二进制数据及混合数据

  • 轻松实现断线重连(轻松实现心跳机制)

  • 支持SSL(jdkssl,openssl)

  • 压力测试

    • 超过200W QPS的处理速度(Http1.1,I7-4790,16.04.1-Ubuntu)  wrk压测

快速入门

  • Maven引用:

  <dependency>
  	<groupId>com.generallycloud</groupId>
  	<artifactId>baseio-all</artifactId>
  	<version>3.2.6.RELEASE</version>
  </dependency>
  • Simple Server:

  public static void main(String[] args) throws Exception {
      IoEventHandle eventHandle = new IoEventHandle() {
          @Override
          public void accept(NioSocketChannel channel, Frame frame) throws Exception {
              FixedLengthFrame f = (FixedLengthFrame) frame;
              frame.write("yes server already accept your message:", channel.getCharset());
              frame.write(f.getReadText(), channel.getCharset());
              channel.flush(frame);
          }
      };
      ChannelContext context = new ChannelContext(8300);
      ChannelAcceptor acceptor = new ChannelAcceptor(context);
      context.addChannelEventListener(new LoggerChannelOpenListener());
      context.setIoEventHandle(eventHandle);
      context.setProtocolCodec(new FixedLengthCodec());
      acceptor.bind();
  }
  • Simple Client:

  public static void main(String[] args) throws Exception {
      IoEventHandle eventHandle = new IoEventHandle() {
          @Override
          public void accept(NioSocketChannel channel, Frame frame) throws Exception {
              FixedLengthFrame f = (FixedLengthFrame) frame;
              System.out.println();
              System.out.println("____________________" + f.getReadText());
              System.out.println();
          }

      };
      ChannelContext context = new ChannelContext(8300);
      ChannelConnector connector = new ChannelConnector(context);
      context.setIoEventHandle(eventHandle);
      context.addChannelEventListener(new LoggerChannelOpenListener());
      context.setProtocolCodec(new FixedLengthCodec());
      NioSocketChannel channel = connector.connect();
      FixedLengthFrame frame = new FixedLengthFrame();
      frame.write("hello server!", channel);
      channel.flush(frame);
      ThreadUtil.sleep(100);
      CloseUtil.close(connector);
  }

更多样例详见 {baseio-test}

本文地址:https://www.codercto.com/soft/d/13568.html

机器学习及其应用2007

机器学习及其应用2007

周志华 编 / 清华大学 / 2007-10 / 37.00元

机器学习是人工智能的一个核心研究领域,也是近年来计算机科学中最活跃的研究分支之一。目前,机器学习技术不仅在计算机科学的众多领域中大显身手,还成为一些交叉学科的重要支撑技术。本书邀请相关领域的专家撰文,以综述的形式介绍机器学习中一些领域的研究进展。全书共分13章,内容涉及高维数据降维、特征选择、支持向量机、聚类、强化学习、半监督学习、复杂网络、异构数据、商空间、距离度量以及机器学习在自然语言处理中的......一起来看看 《机器学习及其应用2007》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具