cURL / Mailing Lists / curl-library / Single Mail

curl-library

using libcurl with persistent connections

From: Keith Broerman <keith.broerman_at_gmail.com>
Date: Tue, 9 Sep 2014 21:31:16 -0400

Hello,

I'm trying to use libcurl to build a HTTP client that subscribes one time
to an event service and waits to receive events on a persistent
connection. I'm starting from the sendrecv.c example code. My
libcurl-based client subscribes to an event by sending a Http Get to my
server-side eventing code (a FastCGI process.) I receive the first event
back OK. But after that point the select() call in wait_on_socket() always
indicates that data is available to be read, when in fact curl_easy_recv()
says there's no data to be read. It's easy to see this by commenting out
the break statement in the sendrecv.c code below.

Any suggestions on what is needed so that the select(readFDs) gets cleared
after curl_easy_recv() says that all data has been read/processed?

Many thanks,

Keith

===============================

snip from sendrecv.c:

    /* read the response */

    for(;;)

    {

      char buf[1024];

      res = wait_on_socket(sockfd, 1, 60000L);

      printf("wait on socket for data = %d\n", res);

      res = curl_easy_recv(curl, buf, 1024, &iolen);

      if(CURLE_OK != res) {

         printf("curl_easy_recv err - done\n");

        //break; <===================== don't break, wait for next
event from server

      }

      else {

        printf("curl_easy_recv OK\n");

        nread = (curl_off_t)iolen;

        printf("Received %" CURL_FORMAT_CURL_OFF_T " bytes.\n", nread);

      }

    } /* read the response */

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-09-10