X-Git-Url: https://gapil.gnulinux.it/gitweb/?a=blobdiff_plain;f=sources%2Fmygetaddr.c;h=d3eb9d8e4912bccac0e6cb6477e99a653490bfbc;hb=31f55ec58bee8b2c4993633849b7da4e30cab222;hp=ca01d74d6a9d951d6ea5c55e44e491d687ae94a6;hpb=839d84a7794ebbde7edafb5b0f30fc3455b26f7b;p=gapil.git diff --git a/sources/mygetaddr.c b/sources/mygetaddr.c index ca01d74..d3eb9d8 100644 --- a/sources/mygetaddr.c +++ b/sources/mygetaddr.c @@ -18,29 +18,27 @@ */ /***************************************************************************** * - * File mygetaddr.c: An example host command + * File mygetaddr.c: An example for getaddrinfo program * * Author: S. Piccardi Nov. 2004 * - * $Id$ - * *****************************************************************************/ -#include -#include -#include -#include -#include /* C standard library */ -#include /* I/O standard library */ -#include +#include /* C strings library */ +#include /* primitive system data types */ +#include /* file characteristics constants and functions */ +#include /* unix standard library */ +#include /* C standard library */ +#include /* I/O standard library */ #include -#include +#include /* socket constants, types and functions */ #include +#include #include "Gapil.h" /* - * Program myhost + * Program mygetaddr * - * Use gethostbyname and print results + * Use getaddrinfo and print results */ /* Help printing routine */ void usage(void); @@ -174,7 +172,7 @@ int main(int argc, char *argv[]) buffer, sizeof(buffer)); } else if (ptr->ai_family == PF_INET6) { /* if IPv6 */ printf("IPv6 address: \n"); - addr6 = (struct sockaddr_in *) ptr->ai_addr; /* address */ + addr6 = (struct sockaddr_in6 *) ptr->ai_addr; /* address */ port = ntohs(addr6->sin6_port); /* port */ string = inet_ntop(addr6->sin6_family, &addr6->sin6_addr, buffer, sizeof(buffer));