X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=listati%2FUDP_ClientEcho.c;h=24bc6d6e47bbdcc02ca2edc736402820ec190554;hp=3cbd3da99e5392139afc329e4fa5fba8a0197166;hb=b9b609733592f0013892cc95e223386282ae6d57;hpb=2a09a578f80e369673bd5ac24179c021e903358b diff --git a/listati/UDP_ClientEcho.c b/listati/UDP_ClientEcho.c index 3cbd3da..24bc6d6 100644 --- a/listati/UDP_ClientEcho.c +++ b/listati/UDP_ClientEcho.c @@ -1,4 +1,4 @@ -void ClientEcho(FILE * filein, int socket, struct sockaddr_in * serv_addr) +void ClientEcho(FILE * filein, int socket) { char sendbuff[MAXLINE+1], recvbuff[MAXLINE+1]; int nread, nwrite; @@ -7,14 +7,13 @@ void ClientEcho(FILE * filein, int socket, struct sockaddr_in * serv_addr) if (fgets(sendbuff, MAXLINE, filein) == NULL) { return; /* if no input just return */ } else { /* else we have to write to socket */ - nwrite = sendto(socket, sendbuff, strlen(sendbuff), 0, - (struct sockaddr *) serv_addr, sizeof(*serv_addr)); + nwrite = write(socket, sendbuff, strlen(sendbuff)); if (nwrite < 0) { /* on error stop */ printf("Errore in scrittura: %s", strerror(errno)); return; } } - nread = recvfrom(socket, recvbuff, strlen(sendbuff), 0, NULL, NULL); + nread = read(socket, recvbuff, strlen(sendbuff)); if (nread < 0) { /* error condition, stop client */ printf("Errore in lettura: %s\n", strerror(errno)); return;