cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Re: ares

From: Giuseppe Attardi <attardi_at_di.unipi.it>
Date: Sun, 21 Sep 2003 10:33:59 +0200

On Thu, 18 Sep 2003, Daniel Stenberg wrote:

> Can you provide us with source code to an app that shows this problem on a
> public URL?

Here is a small program that exhibits the behavior.
It is a little unusual since it reuses the same handle, though
it works fine without ARES.

#include "test.h"

/*
 * Reuse same easy_handle within multi_handle
 * Works fine without ARES.
 */

CURL* init(char* url)
{
  CURL* c = curl_easy_init();
  curl_easy_setopt(c, CURLOPT_URL, url);
  curl_easy_setopt(c, CURLOPT_NOSIGNAL, 1);
  return c;
}

int main(int argc, char **argv)
{
  CURL *c;
  CURLM *m;
  CURLMcode res;
  int running=1;
  int rest = 1;

  curl_global_init(CURL_GLOBAL_ALL);
  m = curl_multi_init();

  c = init("http://extweb.nag.co.uk/robots.txt");
  curl_multi_add_handle(m, c);
  while (running) {
    res = curl_multi_perform(m, &running);
    if (running <= 0) {
      if (rest--) {
        curl_easy_setopt(c, CURLOPT_URL, "http://extweb.nag.co.uk/");
        curl_multi_remove_handle(m, c);
        curl_multi_add_handle(m, c);
        running = 1;
      } else
        break;
    }
  }
  curl_multi_remove_handle(m, c);
  curl_easy_cleanup(c);
  curl_multi_cleanup(m);

  return 0;
}

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-09-21