Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
Próxima revisão | Revisão anterior | ||
pua:resolucao_de_nomes [2008/08/14 00:36] – created maziero | pua:resolucao_de_nomes [2014/03/27 12:30] (atual) – maziero | ||
---|---|---|---|
Linha 1: | Linha 1: | ||
+ | ====== Exemplos de resolução de nomes ====== | ||
+ | |||
+ | ===== Resolução direta ===== | ||
+ | |||
+ | <code c direct-dns.c> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main (int argc, char *argv[]) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | int i ; | ||
+ | | ||
+ | if (argc != 2) | ||
+ | { | ||
+ | fprintf (stderr," | ||
+ | exit (1); | ||
+ | } | ||
+ | | ||
+ | host = gethostbyname (argv[1]) ; | ||
+ | if ( ! host ) | ||
+ | { | ||
+ | herror (" | ||
+ | exit (1); | ||
+ | } | ||
+ | | ||
+ | | ||
+ | for (i=0; host-> | ||
+ | { | ||
+ | bcopy (host-> | ||
+ | printf (" | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Resolução reversa ===== | ||
+ | |||
+ | <code c reverse-dns.c> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main (int argc, char *argv[]) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | int i ; | ||
+ | |||
+ | if (argc != 2) | ||
+ | { | ||
+ | fprintf (stderr," | ||
+ | exit (1); | ||
+ | } | ||
+ | |||
+ | if ( ! inet_aton (argv[1], & | ||
+ | { | ||
+ | perror (" | ||
+ | exit (1) ; | ||
+ | } | ||
+ | |||
+ | host = gethostbyaddr (& | ||
+ | if ( ! host ) | ||
+ | { | ||
+ | herror (" | ||
+ | exit (1); | ||
+ | } | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | for (i=0; host-> | ||
+ | printf (" | ||
+ | } | ||
+ | </ | ||
+ | |||