X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FTCP_echod.c;h=049155744c919942c335a3a5f3b818ce0005990f;hp=576c47f2069ac3d03bcd2b177af409d20f9c9bdb;hb=a7226c68948cc0819518e0733a731d76e4a0e6a5;hpb=58512a223c21f764630ea351c9fac80a25e614fe diff --git a/sources/TCP_echod.c b/sources/TCP_echod.c index 576c47f..0491557 100644 --- a/sources/TCP_echod.c +++ b/sources/TCP_echod.c @@ -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 system functions */ #include /* signal functions */ #include /* error code */ +#include /* 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);