简体   繁体   English

在TCP中提升Asio异步处理程序

[英]Boost asio async handler in tcp

Maybe this is a very simple question but I did not find an answer to that. 也许这是一个非常简单的问题,但我没有找到答案。 I use boost asios tcp class for handling a simple byte protocol. 我使用boost asios tcp类来处理简单的字节协议。 I do async_read_some and the handler does some work. 我做了async_read_some并且处理程序做了一些工作。 After the handler has been completed I start another async_read_some. 处理程序完成后,我将启动另一个async_read_some。 Let's assume this handler does a lot of computing. 假设此处理程序进行了大量计算。 Is there any posibility that incoming data between the handler work and the next call to async_read_some get lost? 在处理程序工作和对async_read_some的下一次调用之间传入的数据是否有丢失的可能性?

No, your OS would continue receiving data until its receive buffers/TCP receive window are full. 不,您的操作系统将继续接收数据,直到其接收缓冲区/ TCP接收窗口已满为止。 Once the receive buffer is full, TCP's flow control will make sure that the sender doesn't send more data than the receiver can receive and such no data will be lost. 一旦接收缓冲区已满,TCP的流控制将确保发送方发送的数据不会超过接收方可以接收的数据,并且不会丢失任何数据。

See https://www.brianstorti.com/tcp-flow-control/ for a good explanation/example. 有关良好的说明/示例,请参见https://www.brianstorti.com/tcp-flow-control/

https://en.wikipedia.org/wiki/Transmission_Control_Protocol#Flow_control https://en.wikipedia.org/wiki/Transmission_Control_Protocol#Flow_control

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM