Modifiche varie per i test delle situazioni limite
[gapil.git] / sources / TCP_echod.c
index 576c47f2069ac3d03bcd2b177af409d20f9c9bdb..049155744c919942c335a3a5f3b818ce0005990f 100644 (file)
@@ -26,7 +26,7 @@
  *
  * Usage: echod -h give all info
  *
- * $Id: TCP_echod.c,v 1.7 2003/06/19 14:18:27 piccardi Exp $ 
+ * $Id: TCP_echod.c,v 1.8 2003/07/27 14:28:19 piccardi Exp $ 
  *
  ****************************************************************/
 /* 
@@ -41,6 +41,7 @@
 #include <syslog.h>      /* syslog system functions */
 #include <signal.h>      /* signal functions */
 #include <errno.h>       /* error code */
+#include <string.h>      /* error code */
 #include "Gapil.h"
 
 #define BACKLOG 10
@@ -198,7 +199,25 @@ void ServEcho(int sockfd) {
     int size;
     /* main loop, reading 0 char means client close connection */
     while ( (nread = read(sockfd, buffer, MAXLINE)) != 0) {
+       if (nread < 0) {
+           snprintf(debug, MAXLINE+20, "Errore in lettura: %s \n", 
+                    strerror(errno));
+           if (demonize) {          /* daemon mode */
+               syslog(LOG_DEBUG, debug);
+           } else {
+               printf("%s", debug);
+           }
+       }
        nwrite = FullWrite(sockfd, buffer, nread);
+       if (nwrite < 0) {
+           snprintf(debug, MAXLINE+20, "Errore in scrittura: %s \n", 
+                    strerror(errno));
+           if (demonize) {          /* daemon mode */
+               syslog(LOG_DEBUG, debug);
+           } else {
+               printf("%s", debug);
+           }       
+       }
        if (debugging) {
            buffer[nread] = 0;
            snprintf(debug, MAXLINE+20, "Letti %d byte, %s", nread, buffer);