cURL / Mailing Lists / curl-library / Single Mail

curl-library

select call returns without any data

From: <centrio_at_gmail.com>
Date: Thu, 07 Jan 2010 08:32:57 +0000

Hi,
I am using a multi handle in my application. I am following the code given
by libcurl website for use of multi handle.

Here is a function that does multi_perform. This method is called in a loop
till we get some data from server (header/body).

void ReceiveData(ConnectionState state) const
{
fd_set read_fds;
fd_set write_fds;
fd_set ex_fds;
int runningHandles = 0;
struct timeval timeOut;
timeOut.tv_sec = 0;
timeOut.tv_usec = 0;

if (CONNECTIONSTATE_CONNECT == state)
{
timeOut.tv_sec = SELECT_CONNECT_TIMEOUT;
}
else if (CONNECTIONSTATE_DATA == state)
{
timeOut.tv_usec = DATA_TIMEOUT;
}

if (sessionData->curlMultiStatusCode == CURLM_OK)
{
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
FD_ZERO(&ex_fds);
int32 max_fd;
sessionData->curlMultiStatusCode =
curl_multi_fdset(sessionData->curlMultiHandle,
&read_fds, &write_fds, &ex_fds, &max_fd);

if (-1 < max_fd)
{
int ret = select(max_fd+1, &read_fds, &write_fds, &ex_fds, &timeOut);
switch(ret)
{
case 0 : //If timeout has occured in CONNECT state then we are not able to
connect to URL
break;
case -1: //Some error has occured on the socket.
sessionData->endOfMedia = true;
sessionData->internalBufferUsed = 0;
break;
}
}
}
sessionData->curlMultiStatusCode =
curl_multi_perform(sessionData->curlMultiHandle, &runningHandles);

if (0 == runningHandles)
{
sessionData->endOfMedia = true;
sessionData->internalBufferUsed = 0;
}
}

I have a timeout of 1 second for select call on curl FD's. For some URLsThe
select call returns before 1 second but no callbacks get called. I wanted
to know why select call returns before 1 second without pulling any data?
Is it because we are sending data to server?? (Get request)

The select is waiting on write_fd's also. Does sending of Get Request to
server changes write_fds?

Is there Any way to know if only read_fds have been modified?

pls help.

Regards
Shivanand

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-01-07