title: libuv event loop and libcurl
body: <p>i see below sample code from <a href="https://gist.github.com/clemensg/5248927#file-curl_libuv_example-c" rel="nofollow noreferrer">An example on how to use libuv with libcurl</a></p>
  
  <p>the main function looks like below:</p>
  
  <pre><code>int main(int argc, char **argv) {
      loop = uv_default_loop();
  
      if (argc &lt;= 1)
          return 0;
  
      if (curl_global_init(CURL_GLOBAL_ALL)) {
          fprintf(stderr, "Could not init cURL\n");
          return 1;
      }
  
      uv_timer_init(loop, &amp;timeout);
  
      curl_handle = curl_multi_init();
      curl_multi_setopt(curl_handle, CURLMOPT_SOCKETFUNCTION, handle_socket);
      curl_multi_setopt(curl_handle, CURLMOPT_TIMERFUNCTION, start_timeout);
  
      while (argc-- &gt; 1) {
          add_download(argv[argc], argc);
      }
  
      uv_run(loop, UV_RUN_DEFAULT);
      curl_multi_cleanup(curl_handle);
      return 0;
  }
  </code></pre>
  
  <p>im confused on how to event loop get going. because it looks like when we execute this line </p>
  
  <pre><code>uv_run(loop, UV_RUN_DEFAULT);
  </code></pre>
  
  <p>there is no pending event in the loop at all so in theory shouldnot the loop exit immediately? </p>
  
  <p>the callback handle_socket should have no changes to run. there is no chance for the <code>curl_perform()</code> to run which is set up in the callbacks of curl socket callbacks. </p>
  
  <p>anything wrong with my understanding?</p>