cURL / Mailing Lists / curl-library / Single Mail


RE: IMAP not working reliably on Win32/VS2012

From: Steve Holme <>
Date: Thu, 5 Sep 2013 21:55:57 +0100

On Thu 5 Sep 2013, Steve Holme wrote:

> Does select() always indicate that there is data waiting to be read
> even after previous reads or is it a one-time notification?

Modifying Curl_pp_statemach() to perform a read into a temporary buffer
seems to solve the problem:
    /* We are receiving and there is data in the cache so just read it */
    rc = 1;
  else if(!pp->sendleft && !Curl_read(conn, sock,buf, sizeof(buf), &nread)
&& nread) {
    /* We have data waiting but may not receive a FDREAD from select() */
    rc = 1;
    pp->cache = malloc(nread);
    pp->cache_size = nread;
    memcpy(pp->cache, buf, nread);
    rc = Curl_socket_ready(pp->sendleft?CURL_SOCKET_BAD:sock, /* reading */
                           pp->sendleft?sock:CURL_SOCKET_BAD, /* writing */

I don't like this, hence why the code isn't production ready (no failed
check on the malloc call) but I'm not sure how else to tackle it at the

Is there a way to test if there is data waiting without using select() /
peek at the socket buffer?

Kind Regards

List admin:
Received on 2013-09-05