[ create a new paste ] login | about

Link: http://codepad.org/jKDeSyYr    [ raw code | fork ]

reel - C, pasted on Dec 4:
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv) {
    if (argc < 2) {
        printf("Usage: %s hostname", argv[0]);
        exit(-1);
    }

    struct hostent *hp;
    while (1)
    {
    hp = gethostbyname(argv[1]);

    if (hp == NULL) {
        printf("gethostbyname() failed\n");
    } else {
        printf("%s = ", hp->h_name);
        unsigned int i=0;
        while ( hp -> h_addr_list[i] != NULL) {
            printf( "%s ", inet_ntoa( *( struct in_addr*)( hp -> h_addr_list[i])));
            i++;
        }
        printf("\n");
    }
    sleep(1);
    }
}


Create a new paste based on this one


Comments: