Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do
- {
- if (m_forceToStop)
- {
- return;
- }
- timeval timeout;
- fd_set fdread;
- fd_set fdwrite;
- fd_set fdexcep;
- int maxfd = -1;
- long curl_timeo = -1;
- FD_ZERO(&fdread);
- FD_ZERO(&fdwrite);
- FD_ZERO(&fdexcep);
- /* set a suitable timeout to play around with */
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
- curl_multi_timeout(multi_handle, &curl_timeo);
- if(curl_timeo >= 0)
- {
- timeout.tv_sec = curl_timeo / 1000;
- if(timeout.tv_sec > 1)
- {
- timeout.tv_sec = 1;
- }
- else
- {
- timeout.tv_usec = (curl_timeo % 1000) * 1000;
- }
- }
- /* get file descriptors from the transfers */
- curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
- /* In a real-world program you OF COURSE check the return code of the
- function calls. On success, the value of maxfd is guaranteed to be
- greater or equal than -1. We call select(maxfd + 1, ...), specially in
- case of (maxfd == -1), we call select(0, ...), which is basically equal
- to sleep. */
- int rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
- curl_multi_perform(multi_handle, &still_running);
- switch(rc)
- {
- case -1: /* select() error */
- {
- break;
- }
- case 0: /* timeout */
- {
- break;
- }
- default: /* action */
- {
- curl_multi_perform(multi_handle, &still_running);
- break;
- }
- }
- } while(still_running);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement