Aggiornamento alla versione reale
[gapil.git] / listati / ServEcho.c
1 void ServEcho(int sockfd) {
2     char buffer[MAXLINE];
3     int nread, nwrite;
4     char debug[MAXLINE+20];
5     /* main loop, reading 0 char means client close connection */
6     while ( (nread = read(sockfd, buffer, MAXLINE)) != 0) {
7         nwrite = FullWrite(sockfd, buffer, nread);
8         if (debugging) {
9             buffer[nread] = 0;
10             snprintf(debug, MAXLINE+20, "Letti %d byte, %s", nread, buffer);
11             if (demonize) {          /* go daemon */
12                 syslog(LOG_DEBUG, debug);
13             } else {
14                 printf("%s", debug);
15             }
16         }
17     }
18     return;
19 }