Reputation: 12138
As stated here, minimum ethernet packet size is 64 bytes:
Ethernet packets with less than the minimum 64 bytes for an Ethernet packet (header + user data + FCS) are padded to 64 bytes
Can I assume that recv
will read in one shot data smaller than the minimum ethernet frame size? Let's say the other end of the connection sends 10 bytes of data in one shot, can I call recv
once on my end and assume all 10 bytes is read?
Upvotes: 0
Views: 307
Reputation: 62563
You can not assume anything when using recv
on TCP socket. It may return any number from -1 (indicating an error) to 0 (indicating a closed socket) to N, where N is equal to buffer size provided to recv
.
Assumptions about number of bytes read by recv
are sources of constant pain and bugs.
Upvotes: 1