Question

While working on a windows application which communicate through winsocket, I've encountred the following scenario:

  1. Alice initiate a tcp session with Bob
  2. Bob accept, and the session is established.
  3. Bob is sending loads of data (~1000 mb) sequancely.
  4. Bob moving on to do other things.
  5. meanwhile, Alice slowly reads the data, N bytes at the time (where N is the size of Alice's buffer, which allocated only once, as the data is written to a file betwin each read. this buffer is allocated by the application).

when debugging this, I found that Bob's send() never blocks, even when I paused Alice before the first read.

question is, what guarantee that the entire data (~1000 mb) will be kept available for Alice to read? is there known/configurable parameter that limit this buffer's length?

Was it helpful?

Solution

Alice has a socket receive buffer, and Bob has a socket send buffer. Both exist for the lifetime of the respective sockets. Data is removed from Bob's buffer when Alice's TCP acknowledges it, and from Alice's buffer when Alice reads it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top