Code RoomSend incomplete on short write
MediumPrep Room Coding #2214

Send incomplete on short write

Code reviewNetworking & APIsMid–Senior~18 min

Review this C function that sends a buffer over a connected socket.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 18 min
Mark a line and say what kind of problem it is.0 findings
1int send_all(int fd, const char *buf, size_t len) {
2 ssize_t n = send(fd, buf, len, 0);
3 if (n < 0) {
4 perror("send");
5 return -1;
6 }
7 return 0;
8}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.