Risistemato tutto il primo esempio di server echo e le funzioni FullWrite e
[gapil.git] / sources / TCP_echod.c
index 049155744c919942c335a3a5f3b818ce0005990f..83d0c738f294743dd66478dfcb9b17d0e0bc7548 100644 (file)
@@ -26,7 +26,7 @@
  *
  * Usage: echod -h give all info
  *
- * $Id: TCP_echod.c,v 1.8 2003/07/27 14:28:19 piccardi Exp $ 
+ * $Id: TCP_echod.c,v 1.9 2003/07/27 23:41:04 piccardi Exp $ 
  *
  ****************************************************************/
 /* 
@@ -41,7 +41,7 @@
 #include <syslog.h>      /* syslog system functions */
 #include <signal.h>      /* signal functions */
 #include <errno.h>       /* error code */
-#include <string.h>      /* error code */
+#include <string.h>      /* error strings */
 #include "Gapil.h"
 
 #define BACKLOG 10
@@ -209,7 +209,7 @@ void ServEcho(int sockfd) {
            }
        }
        nwrite = FullWrite(sockfd, buffer, nread);
-       if (nwrite < 0) {
+       if (nwrite) {
            snprintf(debug, MAXLINE+20, "Errore in scrittura: %s \n", 
                     strerror(errno));
            if (demonize) {          /* daemon mode */
@@ -234,8 +234,8 @@ void ServEcho(int sockfd) {
  * routine to print error on stout or syslog
  */
 void PrintErr(char * error) {
-    if (demonize) {          /* daemon mode */
-       syslog(LOG_ERR, error);
+    if (demonize) {                       /* daemon mode */
+       syslog(LOG_ERR, "%s: %m", error); /* log string and error message */
     } else {
        perror(error);
     }