X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FTCP_echo.c;fp=sources%2FTCP_echo.c;h=57d61840120e90adc83a046a274b62e4a3f1a9a4;hp=c8c5c1ac97910381607852c971c5ce1c3203d11c;hb=af73295172df06a6a91edc4c206b6e5633c566f6;hpb=82d10885f12f0cc6edaa8605cc6cbf03193b595e diff --git a/sources/TCP_echo.c b/sources/TCP_echo.c index c8c5c1a..57d6184 100644 --- a/sources/TCP_echo.c +++ b/sources/TCP_echo.c @@ -26,7 +26,7 @@ * * Usage: echo -h give all info's * - * $Id: TCP_echo.c,v 1.9 2003/10/18 16:30:23 piccardi Exp $ + * $Id: TCP_echo.c,v 1.10 2003/10/19 10:38:27 piccardi Exp $ * ****************************************************************/ /* @@ -144,17 +144,17 @@ void ClientEcho(FILE * filein, int socket) fd_set fset; /* initialize file descriptor set */ FD_ZERO(&fset); - maxfd = max(fileno(stdin), socket) + 1; + maxfd = max(fileno(filein), socket) + 1; while (1) { - FD_SET(socket, &fset); /* set for the socket */ - FD_SET(fileno(stdin), &fset); /* set for the standard input */ + FD_SET(socket, &fset); /* set for the socket */ + FD_SET(fileno(filein), &fset); /* set for the standard input */ select(maxfd, &fset, NULL, NULL, NULL); /* wait for read ready */ - if (FD_ISSET(fileno(stdin), &fset)) { /* if ready on stdin */ + if (FD_ISSET(fileno(filein), &fset)) { /* if ready on stdin */ if (fgets(sendbuff, MAXLINE, filein) == NULL) { /* if no input */ - return; /* we stopped client */ - } else { /* else we have to write to socket */ + return; /* we stopped client */ + } else { /* else we have to write to socket */ nwrite = FullWrite(socket, sendbuff, strlen(sendbuff)); - if (nwrite < 0) { /* on error stop */ + if (nwrite < 0) { /* on error stop */ printf("Errore in scrittura: %s", strerror(errno)); return; }