- 授权协议: Apache
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://www.generallycloud.com/index.html
- 软件文档: https://gitee.com/generallycloud/baseio
软件介绍
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}
数字化生存
(美)Nicholas Negroponte(尼古拉·尼葛洛庞帝) / 胡泳、范海燕 / 电子工业出版社 / 2017-1-1 / 68.00
《数字化生存》描绘了数字科技为我们的生活、工作、教育和娱乐带来的各种冲击和其中值得深思的问题,是跨入数字化新世界的*指南。英文版曾高居《纽约时报》畅销书排行榜。 “信息的DNA”正在迅速取代原子而成为人类生活中的基本交换物。尼葛洛庞帝向我们展示出这一变化的巨大影响。电视机与计算机屏幕的差别变得只是大小不同而已。从前所说的“大众”传媒正演变成个人化的双向交流。信息不再被“推给”消费者,相反,人们或他......一起来看看 《数字化生存》 这本书的介绍吧!
