1 void ClientEcho(FILE * filein, int socket)
3 char sendbuff[MAXLINE+1], recvbuff[MAXLINE+1];
5 /* initialize file descriptor set */
7 if (fgets(sendbuff, MAXLINE, filein) == NULL) {
8 return; /* if no input just return */
9 } else { /* else we have to write to socket */
10 nwrite = write(socket, sendbuff, strlen(sendbuff));
11 if (nwrite < 0) { /* on error stop */
12 printf("Errore in scrittura: %s", strerror(errno));
16 nread = read(socket, recvbuff, strlen(sendbuff));
17 if (nread < 0) { /* error condition, stop client */
18 printf("Errore in lettura: %s\n", strerror(errno));
21 recvbuff[nread] = 0; /* else read is ok, write on stdout */
22 if (fputs(recvbuff, stdout) == EOF) {
23 perror("Errore in scrittura su terminale");