gpt4 book ai didi

c++ - TCP 套接字 : Where does incoming data go after ack(leaves tcp read buffer) but before read()/recv()?

转载 作者:可可西里 更新时间:2023-11-01 02:32:22 26 4
gpt4 key购买 nike

如果我有一个以 200 KB/秒的速度传输数据的 TCP 连接,但我每秒只从套接字read()/recv() 一次,那么在哪里那些 200 KB 的数据同时存储?

据我所知,数据在 ack 发送给发送方后离开 TCP 套接字的读取缓冲区,而且它太小了,无法容纳 200KB 的数据,同时它在哪里等待,直到它可以被 我的客户读取()/recv()

谢谢!!

以下答案声称数据在被 read()/recv()d 之前一收到 ACK 就离开 TCP 读取缓冲区:

https://stackoverflow.com/a/12934115/2378033

“接收器的套接字接收缓冲区的大小决定了在没有确认的情况下可以传输多少数据”

会不会是我的假设是错误的,数据只有在用户空间程序 read()/recv() 之后才会得到 ACK?

最佳答案

data leaves the TCP socket's read buffer after an ack gets sent to the sender

没有。当您通过 recv()、recvfrom()、read()、 等方式读取时,它会离开接收缓冲区。

The following answer claims data leaves the TCP read buffer as soon as it is ACK'ed

费德提克。我写了它,它肯定且绝对没有“声明”任何此类内容。

您正在考虑发送 缓冲区。当数据被接收方确认时,数据将从发送方的发送缓冲区中删除。那是因为发件人现在知道它已经到达并且不再需要它来重新发送。

Could it be that my assumption is wrong and the data gets ACK'd only after it is read()/recv()d by the userspace program?

是的,您的假设是错误的,这种另类推测也是如此。数据在到达时得到确认,并被 read()/recv() 删除。

关于c++ - TCP 套接字 : Where does incoming data go after ack(leaves tcp read buffer) but before read()/recv()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16523946/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com