- Published on
Investigation · Part 4 of 10 · Following a TCP connection
Why recv() Returns Less Than You Asked: TCP Is a Byte Stream
Three send() calls arrived in one recv(), and one send() of 1 MiB arrived in seventeen. TCP keeps the bytes and their order, not the boundaries between your writes. I broke a small JSON reader with two inputs and fixed it with a length prefix and with lines.