X-Git-Url: https://gapil.gnulinux.it/gitweb/?a=blobdiff_plain;f=sources%2FTCP_echo.c;h=86b78c2762a1806840bb757680d6ee0c49d7b317;hb=c48d3a056c974898ca18c27a918f2296c18e2c6e;hp=46ec5ca23d3402d8b080c2748197efec7b181c26;hpb=851bba583269d11d055fcc3701d40492f2abe26b;p=gapil.git diff --git a/sources/TCP_echo.c b/sources/TCP_echo.c index 46ec5ca..86b78c2 100644 --- a/sources/TCP_echo.c +++ b/sources/TCP_echo.c @@ -1,4 +1,4 @@ -/* TCP_echo1.c +/* TCP_echo.c * * Copyright (C) 2001-2003 Simone Piccardi * @@ -18,7 +18,7 @@ */ /**************************************************************** * - * Program ElemEchoTCPClient.c + * Program TCP_echo.c * Simple TCP client for echo service (port 7) * * Author: Simone Piccardi @@ -26,7 +26,7 @@ * * Usage: echo -h give all info's * - * $Id: TCP_echo.c,v 1.6 2003/07/28 22:16:36 piccardi Exp $ + * $Id: TCP_echo.c,v 1.8 2003/08/17 23:03:44 piccardi Exp $ * ****************************************************************/ /* @@ -115,7 +115,6 @@ int main(int argc, char *argv[]) perror("Cannot set linger"); exit(1); } - return 0; } /* do read/write operations */ ClientEcho(stdin, sock); @@ -142,15 +141,22 @@ void ClientEcho(FILE * filein, int socket) while (fgets(sendbuff, MAXLINE, filein) != NULL) { nwrite = FullWrite(socket, sendbuff, strlen(sendbuff)); if (nwrite < 0) { - printf("Errore in scrittura %s", strerror(errno)); + printf("Errore in scrittura: %s", strerror(errno)); + return; } nread = read(socket, recvbuff, strlen(sendbuff)); if (nread < 0) { - printf("Errore in lettura %s\n", strerror(errno)); + printf("Errore in lettura: %s\n", strerror(errno)); + return; + } + if (nread == 0) { + printf("EOF sul socket\n"); + return; } recvbuff[nread] = 0; if (fputs(recvbuff, stdout) == EOF) { perror("Errore in scrittura su terminale"); + return; } } return;