Netty(一) SpringBoot 整合长连接心跳机制

摘要:
基于SpringBoot监控,可以查看实时连接以及各种应用信息。");//向服务端发送消息CustomProtocolheartBeat=SpringBeanFactory.getBean;ctx.writeAndFlush.addListener;}}super.userEventTriggered;}@OverrideprotectedvoidchannelRead0throwsException{//从服务端收到消息时被调用LOGGER.info;}}实现非常简单,只需要在事件回调中发送一个消息即可。由于整合了SpringBoot,所以发送的心跳信息是一个单例的Bean。@ConfigurationpublicclassHeartBeatConfig{@Valueprivatelongid;@BeanpublicCustomProtocolheartBeat(){returnnewCustomProtocol;}}这里涉及到了自定义协议的内容,请继续查看下文。

https://github.com/crossoverJie/JCSprout

原创:crossoverJie阅读原文
前言

Netty 是一个高性能的 NIO 网络框架,本文基于 SpringBoot 以常见的心跳机制来认识 Netty。

最终能达到的效果:

  • 客户端每隔 N 秒检测是否需要发送心跳。

  • 服务端也每隔 N 秒检测是否需要发送心跳。

  • 服务端可以主动 push 消息到客户端。

  • 基于 SpringBoot 监控,可以查看实时连接以及各种应用信息。

效果如下:

Netty(一) SpringBoot 整合长连接心跳机制第1张

IdleStateHandler

Netty 可以使用 IdleStateHandler 来实现连接管理,当连接空闲时间太长(没有发送、接收消息)时则会触发一个事件,我们便可在该事件中实现心跳机制。

客户端心跳

当客户端空闲了 N 秒没有给服务端发送消息时会自动发送一个心跳来维持连接。

核心代码代码如下:

  1. publicclassEchoClientHandleextendsSimpleChannelInboundHandler<ByteBuf>{

  2. privatefinalstaticLoggerLOGGER =LoggerFactory.getLogger(EchoClientHandle.class);

  3. @Override

  4. publicvoiduserEventTriggered(ChannelHandlerContextctx,Objectevt)throwsException{

  5. if(evt instanceofIdleStateEvent){

  6. IdleStateEventidleStateEvent =(IdleStateEvent)evt ;

  7. if(idleStateEvent.state()==IdleState.WRITER_IDLE){

  8. LOGGER.info("已经 10 秒没有发送信息!");

  9. //向服务端发送消息

  10. CustomProtocolheartBeat =SpringBeanFactory.getBean("heartBeat",CustomProtocol.class);

  11. ctx.writeAndFlush(heartBeat).addListener(ChannelFutureListener.CLOSE_ON_FAILURE);

  12. }

  13. }

  14. super.userEventTriggered(ctx,evt);

  15. }

  16. @Override

  17. protectedvoidchannelRead0(ChannelHandlerContextchannelHandlerContext,ByteBufin)throwsException{

  18. //从服务端收到消息时被调用

  19. LOGGER.info("客户端收到消息={}",in.toString(CharsetUtil.UTF_8));

  20. }

  21. }

实现非常简单,只需要在事件回调中发送一个消息即可。

由于整合了 SpringBoot ,所以发送的心跳信息是一个单例的 Bean。

  1. @Configuration

  2. publicclassHeartBeatConfig{

  3. @Value("${channel.id}")

  4. privatelongid ;

  5. @Bean(value ="heartBeat")

  6. publicCustomProtocolheartBeat(){

  7. returnnewCustomProtocol(id,"ping");

  8. }

  9. }

这里涉及到了自定义协议的内容,请继续查看下文。

当然少不了启动引导:

  1. @Component

  2. publicclassHeartbeatClient{

  3. privatefinalstaticLoggerLOGGER =LoggerFactory.getLogger(HeartbeatClient.class);

  4. privateEventLoopGroupgroup =newNioEventLoopGroup();

  5. @Value("${netty.server.port}")

  6. privateintnettyPort;

  7. @Value("${netty.server.host}")

  8. privateStringhost;

  9. privateSocketChannelchannel;

  10. @PostConstruct

  11. publicvoidstart()throwsInterruptedException{

  12. Bootstrapbootstrap =newBootstrap();

  13. bootstrap.group(group)

  14. .channel(NioSocketChannel.class)

  15. .handler(newCustomerHandleInitializer())

  16. ;

  17. ChannelFuturefuture =bootstrap.connect(host,nettyPort).sync();

  18. if(future.isSuccess()){

  19. LOGGER.info("启动 Netty 成功");

  20. }

  21. channel =(SocketChannel)future.channel();

  22. }

  23. }

  24. publicclassCustomerHandleInitializerextendsChannelInitializer<Channel>{

  25. @Override

  26. protectedvoidinitChannel(Channelch)throwsException{

  27. ch.pipeline()

  28. //10 秒没发送消息 将IdleStateHandler 添加到 ChannelPipeline 中

  29. .addLast(newIdleStateHandler(0,10,0))

  30. .addLast(newHeartbeatEncode())

  31. .addLast(newEchoClientHandle())

  32. ;

  33. }

  34. }

所以当应用启动每隔 10 秒会检测是否发送过消息,不然就会发送心跳信息。

Netty(一) SpringBoot 整合长连接心跳机制第2张

服务端心跳

服务器端的心跳其实也是类似,也需要在 ChannelPipeline 中添加一个 IdleStateHandler 。

  1. publicclassHeartBeatSimpleHandleextendsSimpleChannelInboundHandler<CustomProtocol>{

  2. privatefinalstaticLoggerLOGGER =LoggerFactory.getLogger(HeartBeatSimpleHandle.class);

  3. privatestaticfinalByteBufHEART_BEAT =Unpooled.unreleasableBuffer(Unpooled.copiedBuffer(newCustomProtocol(123456L,"pong").toString(),CharsetUtil.UTF_8));

  4. /**

  5. * 取消绑定

  6. * @param ctx

  7. * @throws Exception

  8. */

  9. @Override

  10. publicvoidchannelInactive(ChannelHandlerContextctx)throwsException{

  11. NettySocketHolder.remove((NioSocketChannel)ctx.channel());

  12. }

  13. @Override

  14. publicvoiduserEventTriggered(ChannelHandlerContextctx,Objectevt)throwsException{

  15. if(evt instanceofIdleStateEvent){

  16. IdleStateEventidleStateEvent =(IdleStateEvent)evt ;

  17. if(idleStateEvent.state()==IdleState.READER_IDLE){

  18. LOGGER.info("已经5秒没有收到信息!");

  19. //向客户端发送消息

  20. ctx.writeAndFlush(HEART_BEAT).addListener(ChannelFutureListener.CLOSE_ON_FAILURE);

  21. }

  22. }

  23. super.userEventTriggered(ctx,evt);

  24. }

  25. @Override

  26. protectedvoidchannelRead0(ChannelHandlerContextctx,CustomProtocolcustomProtocol)throwsException{

  27. LOGGER.info("收到customProtocol={}",customProtocol);

  28. //保存客户端与 Channel 之间的关系

  29. NettySocketHolder.put(customProtocol.getId(),(NioSocketChannel)ctx.channel());

  30. }

  31. }

这里有点需要注意

当有多个客户端连上来时,服务端需要区分开,不然响应消息就会发生混乱。

所以每当有个连接上来的时候,我们都将当前的 Channel 与连上的客户端 ID 进行关联(因此每个连上的客户端 ID 都必须唯一)。

这里采用了一个 Map 来保存这个关系,并且在断开连接时自动取消这个关联。

  1. publicclassNettySocketHolder{

  2. privatestaticfinalMap<Long,NioSocketChannel>MAP =newConcurrentHashMap<>(16);

  3. publicstaticvoidput(Longid,NioSocketChannelsocketChannel){

  4. MAP.put(id,socketChannel);

  5. }

  6. publicstaticNioSocketChannelget(Longid){

  7. returnMAP.get(id);

  8. }

  9. publicstaticMap<Long,NioSocketChannel>getMAP(){

  10. returnMAP;

  11. }

  12. publicstaticvoidremove(NioSocketChannelnioSocketChannel){

  13. MAP.entrySet().stream().filter(entry ->entry.getValue()==nioSocketChannel).forEach(entry ->MAP.remove(entry.getKey()));

  14. }

  15. }

启动引导程序:

  1. Component

  2. publicclassHeartBeatServer{

  3. privatefinalstaticLoggerLOGGER =LoggerFactory.getLogger(HeartBeatServer.class);

  4. privateEventLoopGroupboss =newNioEventLoopGroup();

  5. privateEventLoopGroupwork =newNioEventLoopGroup();

  6. @Value("${netty.server.port}")

  7. privateintnettyPort;

  8. /**

  9. * 启动 Netty

  10. *

  11. * @return

  12. * @throws InterruptedException

  13. */

  14. @PostConstruct

  15. publicvoidstart()throwsInterruptedException{

  16. ServerBootstrapbootstrap =newServerBootstrap()

  17. .group(boss,work)

  18. .channel(NioServerSocketChannel.class)

  19. .localAddress(newInetSocketAddress(nettyPort))

  20. //保持长连接

  21. .childOption(ChannelOption.SO_KEEPALIVE,true)

  22. .childHandler(newHeartbeatInitializer());

  23. ChannelFuturefuture =bootstrap.bind().sync();

  24. if(future.isSuccess()){

  25. LOGGER.info("启动 Netty 成功");

  26. }

  27. }

  28. /**

  29. * 销毁

  30. */

  31. @PreDestroy

  32. publicvoiddestroy(){

  33. boss.shutdownGracefully().syncUninterruptibly();

  34. work.shutdownGracefully().syncUninterruptibly();

  35. LOGGER.info("关闭 Netty 成功");

  36. }

  37. }

  38. publicclassHeartbeatInitializerextendsChannelInitializer<Channel>{

  39. @Override

  40. protectedvoidinitChannel(Channelch)throwsException{

  41. ch.pipeline()

  42. //五秒没有收到消息 将IdleStateHandler 添加到 ChannelPipeline 中

  43. .addLast(newIdleStateHandler(5,0,0))

  44. .addLast(newHeartbeatDecoder())

  45. .addLast(newHeartBeatSimpleHandle());

  46. }

  47. }

也是同样将IdleStateHandler 添加到 ChannelPipeline 中,也会有一个定时任务,每5秒校验一次是否有收到消息,否则就主动发送一次请求。

Netty(一) SpringBoot 整合长连接心跳机制第3张

因为测试是有两个客户端连上所以有两个日志。

自定义协议

上文其实都看到了:服务端与客户端采用的是自定义的 POJO 进行通讯的。

所以需要在客户端进行编码,服务端进行解码,也都只需要各自实现一个编解码器即可。

CustomProtocol:

  1. publicclassCustomProtocolimplementsSerializable{

  2. privatestaticfinallongserialVersionUID =4671171056588401542L;

  3. privatelongid ;

  4. privateStringcontent ;

  5. //省略 getter/setter

  6. }

客户端的编码器:

  1. publicclassHeartbeatEncodeextendsMessageToByteEncoder<CustomProtocol>{

  2. @Override

  3. protectedvoidencode(ChannelHandlerContextctx,CustomProtocolmsg,ByteBufout)throwsException{

  4. out.writeLong(msg.getId());

  5. out.writeBytes(msg.getContent().getBytes());

  6. }

  7. }

也就是说消息的前八个字节为 header,剩余的全是 content。

服务端的解码器:

  1. publicclassHeartbeatDecoderextendsByteToMessageDecoder{

  2. @Override

  3. protectedvoiddecode(ChannelHandlerContextctx,ByteBufin,List<Object>out)throwsException{

  4. longid =in.readLong();

  5. byte[]bytes =newbyte[in.readableBytes()];

  6. in.readBytes(bytes);

  7. Stringcontent =newString(bytes);

  8. CustomProtocolcustomProtocol =newCustomProtocol();

  9. customProtocol.setId(id);

  10. customProtocol.setContent(content);

  11. out.add(customProtocol);

  12. }

  13. }

只需要按照刚才的规则进行解码即可。

实现原理

其实联想到 IdleStateHandler 的功能,自然也能想到它实现的原理:

应该会存在一个定时任务的线程去处理这些消息。

来看看它的源码:

首先是构造函数:

  1. publicIdleStateHandler(

  2. intreaderIdleTimeSeconds,

  3. intwriterIdleTimeSeconds,

  4. intallIdleTimeSeconds){

  5. this(readerIdleTimeSeconds,writerIdleTimeSeconds,allIdleTimeSeconds,

  6. TimeUnit.SECONDS);

  7. }

其实就是初始化了几个数据:

  • readerIdleTimeSeconds:一段时间内没有数据读取

  • writerIdleTimeSeconds:一段时间内没有数据发送

  • allIdleTimeSeconds:以上两种满足其中一个即可

因为 IdleStateHandler 也是一种 ChannelHandler,所以会在 channelActive 中初始化任务:

  1. @Override

  2. publicvoidchannelActive(ChannelHandlerContextctx)throwsException{

  3. // This method will be invoked only if this handler was added

  4. // before channelActive() event is fired. If a user adds this handler

  5. // after the channelActive() event, initialize() will be called by beforeAdd().

  6. initialize(ctx);

  7. super.channelActive(ctx);

  8. }

  9. privatevoidinitialize(ChannelHandlerContextctx){

  10. // Avoid the case where destroy() is called before scheduling timeouts.

  11. // See: https://github.com/netty/netty/issues/143

  12. switch(state){

  13. case1:

  14. case2:

  15. return;

  16. }

  17. state =1;

  18. initOutputChanged(ctx);

  19. lastReadTime =lastWriteTime =ticksInNanos();

  20. if(readerIdleTimeNanos >0){

  21. readerIdleTimeout =schedule(ctx,newReaderIdleTimeoutTask(ctx),

  22. readerIdleTimeNanos,TimeUnit.NANOSECONDS);

  23. }

  24. if(writerIdleTimeNanos >0){

  25. writerIdleTimeout =schedule(ctx,newWriterIdleTimeoutTask(ctx),

  26. writerIdleTimeNanos,TimeUnit.NANOSECONDS);

  27. }

  28. if(allIdleTimeNanos >0){

  29. allIdleTimeout =schedule(ctx,newAllIdleTimeoutTask(ctx),

  30. allIdleTimeNanos,TimeUnit.NANOSECONDS);

  31. }

  32. }

也就是会按照我们给定的时间初始化出定时任务。

接着在任务真正执行时进行判断:

  1. privatefinalclassReaderIdleTimeoutTaskextendsAbstractIdleTask{

  2. ReaderIdleTimeoutTask(ChannelHandlerContextctx){

  3. super(ctx);

  4. }

  5. @Override

  6. protectedvoidrun(ChannelHandlerContextctx){

  7. longnextDelay =readerIdleTimeNanos;

  8. if(!reading){

  9. nextDelay -=ticksInNanos()-lastReadTime;

  10. }

  11. if(nextDelay <=0){

  12. // Reader is idle - set a new timeout and notify the callback.

  13. readerIdleTimeout =schedule(ctx,this,readerIdleTimeNanos,TimeUnit.NANOSECONDS);

  14. booleanfirst =firstReaderIdleEvent;

  15. firstReaderIdleEvent =false;

  16. try{

  17. IdleStateEventevent =newIdleStateEvent(IdleState.READER_IDLE,first);

  18. channelIdle(ctx,event);

  19. }catch(Throwablet){

  20. ctx.fireExceptionCaught(t);

  21. }

  22. }else{

  23. // Read occurred before the timeout - set a new timeout with shorter delay.

  24. readerIdleTimeout =schedule(ctx,this,nextDelay,TimeUnit.NANOSECONDS);

  25. }

  26. }

  27. }

如果满足条件则会生成一个 IdleStateEvent 事件。

SpringBoot 监控

由于整合了 SpringBoot 之后不但可以利用 Spring 帮我们管理对象,也可以利用它来做应用监控。

actuator 监控

当我们为引入了:

  1. <dependency>

  2. <groupId>org.springframework.boot</groupId>

  3. <artifactId>spring-boot-starter-actuator</artifactId>

  4. </dependency>

就开启了 SpringBoot 的 actuator 监控功能,他可以暴露出很多监控端点供我们使用。

如一些应用中的一些统计数据:Netty(一) SpringBoot 整合长连接心跳机制第4张

存在的 Beans:Netty(一) SpringBoot 整合长连接心跳机制第5张

更多信息请查看:https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

但是如果我想监控现在我的服务端有多少客户端连上来了,分别的 ID 是多少?

其实就是实时查看我内部定义的那个关联关系的 Map。

这就需要暴露自定义端点了。

自定义端点

暴露的方式也很简单:

继承 AbstractEndpoint 并复写其中的 invoke 函数:

  1. publicclassCustomEndpointextendsAbstractEndpoint<Map<Long,NioSocketChannel>>{

  2. /**

  3. * 监控端点的 访问地址

  4. * @param id

  5. */

  6. publicCustomEndpoint(Stringid){

  7. //false 表示不是敏感端点

  8. super(id,false);

  9. }

  10. @Override

  11. publicMap<Long,NioSocketChannel>invoke(){

  12. returnNettySocketHolder.getMAP();

  13. }

  14. }

其实就是返回了 Map 中的数据。

再配置一个该类型的 Bean 即可:

  1. @Configuration

  2. publicclassEndPointConfig{

  3. @Value("${monitor.channel.map.key}")

  4. privateStringchannelMap;

  5. @Bean

  6. publicCustomEndpointbuildEndPoint(){

  7. CustomEndpointcustomEndpoint =newCustomEndpoint(channelMap);

  8. returncustomEndpoint ;

  9. }

  10. }

这样我们就可以通过配置文件中的 monitor.channel.map.key 来访问了:

一个客户端连接时:Netty(一) SpringBoot 整合长连接心跳机制第6张

两个客户端连接时:Netty(一) SpringBoot 整合长连接心跳机制第7张

整合 SBA

这样其实监控功能已经可以满足了,但能不能展示的更美观、并且多个应用也可以方便查看呢?

有这样的开源工具帮我们做到了:

https://github.com/codecentric/spring-boot-admin

简单来说我们可以利用该工具将 actuator 暴露出来的接口可视化并聚合的展示在页面中:

Netty(一) SpringBoot 整合长连接心跳机制第8张

接入也很简单,首先需要引入依赖:

  1. <dependency>

  2. <groupId>de.codecentric</groupId>

  3. <artifactId>spring-boot-admin-starter-client</artifactId>

  4. </dependency>

并在配置文件中加入:

  1. # 关闭健康检查权限

  2. management.security.enabled=false

  3. # SpringAdmin 地址

  4. spring.boot.admin.url=http://127.0.0.1:8888

在启动应用之前先讲 SpringBootAdmin 部署好:

这个应用就是一个纯粹的 SpringBoot ,只需要在主函数上加入 @EnableAdminServer 注解。

  1. @SpringBootApplication

  2. @Configuration

  3. @EnableAutoConfiguration

  4. @EnableAdminServer

  5. publicclassAdminApplication{

  6. publicstaticvoidmain(String[]args){

  7. SpringApplication.run(AdminApplication.class,args);

  8. }

  9. }

引入:

  1. <dependency>

  2. <groupId>de.codecentric</groupId>

  3. <artifactId>spring-boot-admin-starter-server</artifactId>

  4. <version>1.5.7</version>

  5. </dependency>

  6. <dependency>

  7. <groupId>de.codecentric</groupId>

  8. <artifactId>spring-boot-admin-server-ui</artifactId>

  9. <version>1.5.6</version>

  10. </dependency>

之后直接启动就行了。

这样我们在 SpringBootAdmin 的页面中就可以查看很多应用信息了。

Netty(一) SpringBoot 整合长连接心跳机制第9张

更多内容请参考官方指南:

http://codecentric.github.io/spring-boot-admin/1.5.6/

自定义监控数据

其实我们完全可以借助 actuator 以及这个可视化页面帮我们监控一些简单的度量信息。

比如我在客户端和服务端中写了两个 Rest 接口用于向对方发送消息。

只是想要记录分别发送了多少次:

客户端:

  1. @Controller

  2. @RequestMapping("/")

  3. publicclassIndexController{

  4. /**

  5. * 统计 service

  6. */

  7. @Autowired

  8. privateCounterServicecounterService;

  9. @Autowired

  10. privateHeartbeatClientheartbeatClient ;

  11. /**

  12. * 向服务端发消息

  13. * @param sendMsgReqVO

  14. * @return

  15. */

  16. @ApiOperation("客户端发送消息")

  17. @RequestMapping("sendMsg")

  18. @ResponseBody

  19. publicBaseResponse<SendMsgResVO>sendMsg(@RequestBodySendMsgReqVOsendMsgReqVO){

  20. BaseResponse<SendMsgResVO>res =newBaseResponse();

  21. heartbeatClient.sendMsg(newCustomProtocol(sendMsgReqVO.getId(),sendMsgReqVO.getMsg()));

  22. // 利用 actuator 来自增

  23. counterService.increment(Constants.COUNTER_CLIENT_PUSH_COUNT);

  24. SendMsgResVOsendMsgResVO =newSendMsgResVO();

  25. sendMsgResVO.setMsg("OK");

  26. res.setCode(StatusEnum.SUCCESS.getCode());

  27. res.setMessage(StatusEnum.SUCCESS.getMessage());

  28. res.setDataBody(sendMsgResVO);

  29. returnres ;

  30. }

  31. }

只要我们引入了 actuator 的包,那就可以直接注入 counterService ,利用它来帮我们记录数据。

当我们调用该接口时:

Netty(一) SpringBoot 整合长连接心跳机制第10张

Netty(一) SpringBoot 整合长连接心跳机制第11张

在监控页面中可以查询刚才的调用情况:

Netty(一) SpringBoot 整合长连接心跳机制第12张

服务端主动 push 消息也是类似,只是需要在发送时候根据客户端的 ID 查询到具体的 Channel 发送:

Netty(一) SpringBoot 整合长连接心跳机制第13张

Netty(一) SpringBoot 整合长连接心跳机制第14张

Netty(一) SpringBoot 整合长连接心跳机制第15张

总结

以上就是一个简单 Netty 心跳示例,并演示了 SpringBoot 的监控,之后会继续更新 Netty 相关内容,欢迎关注及指正。

本文所有代码:

https://github.com/crossoverJie/netty-action

号外

最近在总结一些 Java 相关的知识点,感兴趣的朋友可以一起维护。

地址: https://github.com/crossoverJie/Java-Interview

阅读原文

免责声明:文章转载自《Netty(一) SpringBoot 整合长连接心跳机制》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇对比SerialCommunication和微软的SerialPort,向SerialPort看齐android项目 添加下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Netty 业务处理:ChannelHandler家族

ChannelHandler 接口 类型 描述 handlerAdded ChannelHandler添加到ChannelPipeline时被调用 handlerRemoved ChannelHandler从ChannelPipeline时被调用 exceptionCaught 处理过程中ChannelPipeline有错误 Cha...

TCP keepalive长连接心跳保活

比如:客户端与服务端进行握手时,经常无法握手成功,收不到回复; 需要建立保活机制。 1. 服务端Linux服务器新增系统内核参数配置。 在/etc/sysctl.conf文件中再添加如: #允许的持续空闲时长,在TCP保活打开的情况下,最后一次数据交换到TCP发送第一个保活探测包的间隔,即允许的持续空闲时长,或者说每次正常发送心跳的周期,默认值为7200s...

netty之SSL协议-netty学习笔记(8)-20210806

1、SSL/TLS简介 协议是Web浏览器与Web服务器之间安全交换信息的协议,提供两个基本的安全服务:鉴别与保密。 1.1、作用 不使用SSL/TLS的HTTP通信,就是不加密的通信。所有信息明文传播,带来了三大风险。 窃听风险(eavesdropping):第三方可以获知通信内容。 篡改风险(tampering):第三方可以修改通信内容。 冒...

Modbus协议服务端(Netty)

pom.xml <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>4.0.21.Final...

netty作为基础通信组件

阿里分布式服务框架 Dubbo 的 RPC 框架使用 Dubbo 协议进行节点间通信,Dubbo 协议默认使用 Netty 作为基础通信组件,用于实现各进程节点之间的内部通信。其中,服务提供者和服务消费者之间,服务提供者、服务消费者和性能统计节点之间使用 Netty 进行异步/同步通信。     除了 Dubbo 之外,淘宝的消息中间件 RocketMQ...

Netlink机制详解

使用netlink机制在内核与应用程序之间通信 https://blog.csdn.net/zhongbeida_xue/article/details/79026398 转载:https://blog.csdn.net/zoe6553/article/details/8026033 前一段时间,在开发一个驱动程序的过程中,需要在驱动程序与应用程序之间进行...