Truncated And Silent

This datagram server works fine against the test client, which sends 200 byte messages. A new client sends a single 1200 byte datagram in one sendto() call.

char buf[512];

for (;;) {
    struct sockaddr_storage from;
    socklen_t fromlen = sizeof from;

    ssize_t n = recvfrom(sfd, buf, sizeof buf, 0,
                         (struct sockaddr *)&from, &fromlen);
    if (n < 0) { perror("recvfrom"); continue; }

    handle(buf, (size_t)n);   /* parse one complete message */
}

What does handle() see for that 1200 byte datagram?

A

One call with 1200 bytes, because recvfrom allocates as much as the datagram needs.

B

One call with 512 bytes. The other 688 are discarded and no later call returns them.

C

Three calls: 512, 512, then 176 bytes.

D

No call at all. recvfrom returns -1 and sets errno to EMSGSIZE.