I've recently put together a quick little program to read mail from a POP3 server. It reads in data up to 2KB at a time and stuffs it into a larger buffer to pull lines from. It almost never reads the limit. But is this any different from simply reading up to a complete line and going from there? My way seems rather complicated, but I don't really know how sockets are handled. It's my understanding that the OS (in this case Windows) maintains a receive buffer for each open socket. send() calls from the server should complete normally until this buffer is full, correct?

My approach is to pull off as much data as possible and sort it as opposed to only reading what I need. In theory if my program was running on a really slow CPU then during this time the OS's buffer would become full and send() for the server would block (if in blocking mode).

Am I right in my thinking?