1 int main(int argc, char *argv[])
10 char buffer[INET6_ADDRSTRLEN];
15 if ((argc - optind) != 1) {
16 printf("Wrong number of arguments %d\n", argc - optind);
20 data = gethostbyname(argv[1]);
22 herror("Errore di risoluzione");
25 printf("Canonical name %s\n", data->h_name);
26 alias = data->h_aliases;
27 while (*alias != NULL) {
28 printf("Alias %s\n", *alias);
31 if (data->h_addrtype == AF_INET) {
32 printf("Address are IPv4\n");
33 } else if (data->h_addrtype == AF_INET6) {
34 printf("Address are IPv6\n");
36 printf("Tipo di indirizzo non valido\n");
39 alias = data->h_addr_list;
40 while (*alias != NULL) {
41 addr = inet_ntop(data->h_addrtype, *alias, buffer, sizeof(buffer));
42 printf("Indirizzo %s\n", addr);