In: size_t rest(length); // Just keep writing until all is written while (rest) { ssize_t written(write(fd, buffer, rest)); if (rest == -1) { ^^^^ should be written BTW the same bug is in the read, rest in == -1 must be replaced by amount Regards Francis Dupont <fdupont at isc.org>