I'm using libevent for creating a small p2p network.
Let's say that I want to send 10,000 bytes buffer from one node to another, due to libevent the max size that can be send in one time is 4,096 bytes (so 4,096 + 4,096 + 1,808).
Is it technically possible (in TCP protocol) for the node that receives the data, to know the total number of bytes that will be sent when receives the first 4,096 bytes ?
No. It is, however, common for the application protocol to tell the receiver how many bytes to expect. With HTTP 1.1, it's the
Content-Lengthheader. You can also use length prefix along the lines of<len><data>. PostgresSQL uses that protocol between the front and backend.