I'm building a full-stack application where the server is to be capable of maintaining connections with multiple clients at the same time. Communication will be done via TCP-IP. Since most of the data transferred will be very small, I've compromised to set the buffer to 4096 bytes for both ends.
However, entire files will eventually be transferred through this same connection. Since these files may potentially be multiple MB in size, I've been questioning myself: which is the best approach, to send one large packet or send many 4096B packets to the client?
In the case of using one big packet, how will the client deal with it given that the client's buffer is 4096 bytes as well? Will it "receive" many packets until the original packet is entirely consumed by the buffer or will the overflown data be lost?