void ServEcho(int sockfd) {
char buffer[MAXLINE];
int nread, nwrite;
-
+ char debug[MAXLINE+20];
/* main loop, reading 0 char means client close connection */
while ( (nread = read(sockfd, buffer, MAXLINE)) != 0) {
- nwrite = FullWrite(sockfd, buffer, nread);
+ if (debugging) {
+ snprintf(debug, MAXLINE+20, "Letti %d bytes, %s\n", nread, buffer);
+ debug[strlen(debug)] = 0;
+ if (demonize) { /* go daemon */
+ syslog(LOG_DEBUG, debug);
+ } else {
+ fputs(debug, stdout);
+ }
+ }
+ nwrite = FullWrite(sockfd, buffer, nread);
}
return;
}