1

Let's say a Server sends a small amount of data, but a Client never calls recv(), will the data sent by the Server be present in an internal receive buffer on the Client side even though read(), recv(), ... were never called?

err69
  • 317
  • 1
  • 7
  • 1
    yes. the entire concept of TCP Window Size is based on that. It happens in UDP as well, try it! – Yarin_007 Feb 19 '23 at 23:15
  • 1
    @Yarin_007, is there any way to get how full the internal buffer is, without actually reading it? – err69 Feb 19 '23 at 23:21
  • On linux it seems to be [pretty easy](https://stackoverflow.com/a/56279407/4935162), for TCP. In windows (or linux...) i *guess* you could spin up wireshark and look at the (calculated) window size there, on, say, the first packet your process sends after the # way handshake. (i say calculated because in the TCP handshake the 2 sides agree on a multiplication - scaling factor. wireshark parses it and displays it.) – Yarin_007 Feb 19 '23 at 23:31
  • 1
    Knowing how full the internal buffer is, is less helpful than you might imagine, since the number reported to you might already be out-of-date by the time you act on it. (e.g. between the time the value is returned and the time you examine it, more data might have been received from the network and added to the buffer) – Jeremy Friesner Feb 20 '23 at 05:47
  • 1
    @err69 on 'Nix systems, you can use `ioctl(FIONREAD)`, on Windows you can use `ioctlsocket(FIONREAD)`. – Remy Lebeau Feb 21 '23 at 06:06

0 Answers0