cURL / Mailing Lists / curl-library / Single Mail

curl-library

is curl_multi_socket_all() deprecated?

From: <ragnar_at_gatorhole.com>
Date: Wed, 22 Oct 2008 12:53:04 +0200 (CEST)

I have another question for the list - the documentation states that
curl_multi_socket() and curl_multi_socket_all() are deprecated, and that
curl_multi_socket_action() should be used instead.

However, is curl_multi_socket_all() really deprecated? How do you "start"
execution without calling curl_multi_socket_all() at least once?

I.e.

int curl_socket_cb(CURL *easy, curl_socket_t s, int action, void *userp,
void *socketp)
{
  // add new socket to epoll set that we use for polling
  add_to_my_epoll_set(s, action);
}

main() {

  init_stuff();

  // set socket callback
  curl_multi_setopt(multi_handle, CURLMOPT_SOCKETFUNCTION, curl_socket_cb);

  // setup easy handles
  for (i=0; i<10; i++) {
    easy_handles[i] = curl_easy_init();
    curl_easy_setopt(ret, CURLOPT_URL, some_url);
    curl_multi_add_handle(multi_handle, easy_handles[i]);
  }

  // Call curl_multi_socket_all() to "start" things up, make CURL create
  // sockets etc. We cannot use curl_multi_socket_action() for this since
  // we don't yet know what file descriptors CURL is using.
  do {
    rc = curl_multi_socket_all(multi_handle, &running_handles);
  } while (rc == CURLM_CALL_MULTI_PERFORM);

  // main loop
  while (running_handles > 0) {
    poll_for_events();
    if (event)
      curl_multi_socket_action(...)
  }

}
Received on 2008-10-22