X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FUDP_echo.c;h=238effb3bdc49ad257410e56dcca0604962b5559;hp=a3bbd9b8c4fac087caacace36f33ed3fcda45652;hb=1bc54870307368cc8c74e07f7f4dd53498e09db0;hpb=2a09a578f80e369673bd5ac24179c021e903358b diff --git a/sources/UDP_echo.c b/sources/UDP_echo.c index a3bbd9b..238effb 100644 --- a/sources/UDP_echo.c +++ b/sources/UDP_echo.c @@ -26,7 +26,7 @@ * * Usage: echo -h give all info's * - * $Id: UDP_echo.c,v 1.3 2004/06/02 16:31:50 piccardi Exp $ + * $Id: UDP_echo.c,v 1.4 2004/06/04 00:31:33 piccardi Exp $ * ****************************************************************/ /* @@ -39,12 +39,13 @@ #include /* include standard I/O library */ #include /* include error codes */ #include /* include erroro strings definitions */ +#include #include "macros.h" #define MAXLINE 256 void usage(void); -void ClientEcho(FILE * filein, int socket, struct sockaddr_in *serv_add); +void ClientEcho(FILE * filein, int socket); void SigTERM_hand(int sig); /* Program begin */ @@ -54,7 +55,7 @@ int main(int argc, char *argv[]) * Variables definition */ int sock, i; - struct sockaddr_in serv_add; + struct sockaddr_in dst_addr; /* * Input section: decode parameters passed in the calling * Use getopt function @@ -90,15 +91,15 @@ int main(int argc, char *argv[]) return 1; } /* initialize address */ - memset((void *) &serv_add, 0, sizeof(serv_add)); /* clear server address */ - serv_add.sin_family = AF_INET; /* address type is INET */ - serv_add.sin_port = htons(7); /* echo port is 7 */ + memset((void *) &dst_addr, 0, sizeof(dst_addr)); /* clear address */ + dst_addr.sin_family = AF_INET; /* address type is INET */ + dst_addr.sin_port = htons(7); /* echo port is 7 */ /* build address using inet_pton */ - if ( (inet_pton(AF_INET, argv[optind], &serv_add.sin_addr)) <= 0) { + if ( (inet_pton(AF_INET, argv[optind], &dst_addr.sin_addr)) <= 0) { perror("Address creation error"); return 1; } - connect(sock, &serv_add, sizeof(*serv_add)); + connect(sock, (struct sockaddr *) &dst_addr, sizeof(dst_addr)); /* do read/write operations */ ClientEcho(stdin, sock); /* normal exit */