Search code examples
csocketsethernet

Can an ethernet buffer fill up and not allow another process to recv() ethernet packets?


Say you have a process that receives a large file from a server.

  1. If you do not perform a recv() call does it stay on a buffer of your ethernet controller forever?

  2. If another process needs to receive data and the buffer is full from another process does it need to wait until the other process performs a recv() or the buffer times out?

  3. If you have multiple process sending and receiving data does it have to wait until the buffer is empty.? Or can it multiplex it and keep track at the driver level or some part of the socket library?

edit: spelling


Solution

    1. If you do not perform a recv() call does it stay on a buffer of your ethernet controller forever?

    No, data never stays in the ethernet controller's buffer for very long; the kernel will read the data out of the Ethernet controller's buffer and into your socket's buffer (in the computer's regular RAM) as quickly as it can. If your socket's buffer is full, then the incoming data will be discarded.

    1. If another process needs to receive data and the buffer is full from another process does it need to wait until the other process performs a recv() or the buffer times out?

    Each socket has its own separate buffer in the computer's main RAM, and each process has its own socket(s), so processes do not have to wait for each others' buffers to empty.

    1. If you have multiple process sending and receiving data does it have to wait until the buffer is empty.?

    See the answer to question 2, as it answers this question also.