#include <stdio.h>

#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

int main(int argc, char *argv[])
{
    int i, bytes_written=0;
    CURL *curl_handle;
    char errbuf[CURL_ERROR_SIZE];
    
    if (argc < 2) {
        fprintf(stderr, "usage: %s url\n", argv[0]);
        exit(1);
    }

for (i=0; i<10000; i++) {
    /* Init the curl session */
    curl_handle = curl_easy_init();

    /* Set URL to get */
    curl_easy_setopt(curl_handle, CURLOPT_URL, argv[1]);

    /* No progress meter please */
    curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1);

    /* Shut up completely */
    curl_easy_setopt(curl_handle, CURLOPT_MUTE, 1);

    /* Follow location headers */
    curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);

    /* Save cookies */
    curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, "cookies");

    /* Set timeout */
    curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 30);

    /* Store error messages here */
    curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, errbuf);

    /* get it! */
    if (curl_easy_perform(curl_handle) != 0) {
        printf("Error: %s\n", errbuf);
    } else {
        printf("Ok: %d bytes received\n", bytes_written);
    }

    /* cleanup curl stuff */
    curl_easy_cleanup(curl_handle);

#if 0
	char *str ="";
	struct hostent *p;
	p = gethostbyname("www.google.com");

	printf("addr = %s\n",inet_ntoa(*(int*)(p->h_addr_list[0])));
#endif
   }	
}

