简体   繁体   中英

What happens to messages sent by sending socket but never read by receiving socket?

Suppose that I have a sender socket and receiver socket. The sender socket sends messages which are 1 GB in total, but the receiver socket neither read from nor close the socket.

What happens to the 1GB of messages before either socket closes? Are they sitting somewhere in OS buffer?

To be more specific...

  • Each sender has its own thread.
  • All senders have flushed their output stream.
  • All messages are passed by loopback interface

Yes the data will be sitting in buffers in the TCP/IP stack. Though it is far far less than 1Gb.

Assuming you use TCP - which employs flow control to deal with such a situation, the receiver buffers will fill up. When the receiver buffer is full the sender will stop transmitting. The sender buffer will fill up, and when it is full, the application write/send calls will block until the receiver starts consuming the data or an error occurs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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