且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当内部缓冲区填满时,TCP中会发生什么

更新时间:2023-11-08 11:26:34

内部网络缓冲区可以填满吗?

Can the internal network buffer fill up?

有两个 内部缓冲区:发送缓冲区和接收缓冲区.两者都可以填满.

There are two internal buffers: the send buffer and the receive buffer. Both can fill up.

我认为答案是肯定的...

I assume the answer is yes...

是的

如果是,那么TCP协议是否指定在这种情况下会发生什么?

If so, then does the TCP protocol specify what will happen in this scenario?

是的

这些丢弃的数据包是

Are these discarded packets

没有丢弃的数据包.在这种情况下,TCP不会丢弃数据包.发送缓冲区填满时会发生什么情况取决于您是处于阻塞模式还是非阻塞模式,或者您是否正在使用异步API:

There are no discarded packets. TCP does not discard packets in this circumstance. What happens when the send buffer fills depends on whether you are in blocking or non-blocking mode, or whether you are using an asynchronous API:

  • 阻止模式:发送方阻止
  • 非阻止模式:发送方收到错误EAGAIN/EWOULDBLOCK
  • 异步:此操作将继续推迟.

将它们当作在运输途中丢失了,就像其他丢失的包裹一样重新传输了?

treated as if they were lost in transit and just re-transmitted like any other lost packages?

不.见上文.

这些数据包真的丢失了吗?

Or are these packets truly lost

不.见上文.

在基于TCP的协议上设计自己的通信协议时,我必须考虑这一点吗?

and this something I have to consider when desiging my own communication protocol on top of the TCP?

不.看上面.但是,在协议的实现中肯定要考虑各种条件.

No. See above. But the various conditions are certainly something you have to consider in your implementation of the protocol.

答案在不同的操作系统之间会有所不同吗?

Does the answer vary between operating systems?

否.

作为记录,上面的系统应该具有某种拥塞控制机制

For a record, the system above should have some kind of congestion control mechanism

TCP已经具有拥塞控制机制.

TCP already has a congestion control mechanism.

哪个服务器可以用来告诉客户端负载很重

which server could use to tell the client that it's under heavy load

如何?如果客户端没有阅读,服务器如何告知呢?

How? if the client isn't reading, how can the server tell it anything?

或再次免费.但是,我很想知道默认情况下TCP在这种情况下的行为.

or it's free again. However, I'm curious to know how the TCP by the default would behave in this scenario.

请参阅上文.