我可以假设 recv 将读取小于最小以太网帧大小的一次性数据吗?

Can I assume that recv will read in one shot data smaller than the minimum ethernet frame size?

如所述here,最小以太网数据包大小为 64 字节:

Ethernet packets with less than the minimum 64 bytes for an Ethernet packet (header + user data + FCS) are padded to 64 bytes

我可以假设 recv 一次性读取小于最小以太网帧大小的数据吗?假设连接的另一端一次发送 10 个字节的数据,我可以在我这边调用一次 recv 并假设所有 10 个字节都已读取吗?

在 TCP 套接字上使用 recv 时,您不能假设 任何东西 。它可以 return 从 -1(表示错误)到 0(表示套接字关闭)到 N 的任何数字,其中 N 等于提供给 recv.

的缓冲区大小

关于 recv 读取的字节数的假设是持续痛苦和错误的根源。