6 ms·
> The naive TCP echo server would look like: while data: data = read(sd, 4096) write(sd, data) Not if that’s the write syscall, since it c
by amluto 8y ago
> The naive TCP echo server would look like:
while data:
data = read(sd, 4096)
write(sd, data)
Not if that’s the write syscall, since it can return with fewer bytes than requested having been written. The full C code detects this case and crashes, which looks totally wrong.
The Python-ish example should, at the very least, use sendall. But even that is potentially suboptimal.