Aggiornamento alla versione reale
[gapil.git] / listati / ServEcho.c
index 0ea06359a7907d3364180a883f8be0b7ab385da5..686c14ae05514f2b6af972ffe0b716e1d3a242e3 100644 (file)
@@ -4,16 +4,16 @@ void ServEcho(int sockfd) {
     char debug[MAXLINE+20];
     /* main loop, reading 0 char means client close connection */
     while ( (nread = read(sockfd, buffer, MAXLINE)) != 0) {
     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) {
        if (debugging) {
-           snprintf(debug, MAXLINE+20, "Letti %d bytes, %s\n", nread, buffer);
-           debug[strlen(debug)] = 0;
+           buffer[nread] = 0;
+           snprintf(debug, MAXLINE+20, "Letti %d byte, %s", nread, buffer);
            if (demonize) {          /* go daemon */
                syslog(LOG_DEBUG, debug);
            } else {
            if (demonize) {          /* go daemon */
                syslog(LOG_DEBUG, debug);
            } else {
-               fputs(debug, stdout);
+               printf("%s", debug);
            }
        }
            }
        }
-       nwrite = FullWrite(sockfd, buffer, nread);
     }
     return;
 }
     }
     return;
 }