For the TCP RECV command, one provides a string to be used as a buffer, and the amount of data they want. My question is this:
In straight winsock, when doing a recv usually I would loop asking for a chunk at a time for very large transfers (such as 50mb or larger maybe). Perhaps chunks of 4k or 64k, etc. This was because recv wanted a buffer that was already allocated and I didn't want to be allocating 50 meg buffers and getting a few hundred K on each call.
So my question is how TCP RECV works. If I'm expecting a 250mb receive, should I be doing buffers of 4k (or some other value), or am I OK to loop, asking for the entire amount yet to be received each time. Does TCP RECV allocate the buffer of the size I specify all at once, or internally does it split it into chunks, etc?
How is that usually handled best to avoid wasting memory, but also to maximize transfer speed?
In straight winsock, when doing a recv usually I would loop asking for a chunk at a time for very large transfers (such as 50mb or larger maybe). Perhaps chunks of 4k or 64k, etc. This was because recv wanted a buffer that was already allocated and I didn't want to be allocating 50 meg buffers and getting a few hundred K on each call.
So my question is how TCP RECV works. If I'm expecting a 250mb receive, should I be doing buffers of 4k (or some other value), or am I OK to loop, asking for the entire amount yet to be received each time. Does TCP RECV allocate the buffer of the size I specify all at once, or internally does it split it into chunks, etc?
How is that usually handled best to avoid wasting memory, but also to maximize transfer speed?
Comment