int nbytes;
// Read from client
nbytes = read(filedes, buffer, 1024);
// Check for error
if (nbytes < 0) {
perror("read");
exit(EXIT_FAILURE);
} else if (nbytes == 0) {
throw recverror();
} else if (nbytes == 1) {
throw nomessage();
}
// Make sure string is terminated correctly
buffer[nbytes - 1] = 0;
// Log and return
std::clog << nbytes - 1 << "> " << buffer << std::endl;
return buffer;
}
It must be in here, could you take a quick look?
use a proper ide with proper analyzers and warning system and follow its hints.
Обсуждают сегодня