guowenxue
2021-04-21 a01524eb28cce72db4b499ec242995fbf99b6b7a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*********************************************************************************
 *      Copyright:  (C) 2018 LingYun IoT Studio
 *                  All rights reserved.
 *
 *       Filename:  dns_main.c
 *    Description:  This file is DNS client API test entry(main) file
 *                 
 *        Version:  1.0.0(10/29/2018)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "2018-10-28 01:38:08 PM"
 *                 
 ********************************************************************************/ 
 
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
 
#include "dns_api.h"
 
int main(int argc,char* argv[])
{
    char                 *hostname;
    char                  ipaddr[IPADDR_LEN];
 
    if(argc != 2)
    {
        printf("Usage: %s [domain]\n", argv[0]);
        return 1;
    }
 
    hostname=argv[1];
 
    memset( ipaddr, 0, sizeof(ipaddr) );
    query_dns("114.114.114.114", hostname, ipaddr, IPADDR_LEN);
 
    printf("DNS query: %s->%s\n", hostname, ipaddr); 
    
    return 0;
}