From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 7 Jan 2010 09:56:06 +0100 (CET)

On Thu, 7 Jan 2010, centrio_at_gmail.com wrote:


if (CONNECTIONSTATE_CONNECT == state)


#How does your program know/guess what state the handle is in?

Initially the application when receives a URL to connect to, its in Connect state. I switch to Data state once I get atleast one Data callback. (WRITE_DATA).


switch(ret)
{
case 0 : //If timeout has occured in CONNECT state then we are not able to
connect to URL
break;


#... your code can't easily know if libcurl is in "connect state" or not thus
#you can't tell the importance from a select() timeout that way.

As long as no data_callback is called, I assume I am in connection state. In connecting state, I will send a GET request and wait for all the headers to come in Header callback. The moment first data callback is called, I switch state to DATA.


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.


#That's normal and expected.

If select is returning before 1 second, (no timeout) then it mean it has returned because it has observed some change on FD's. Now if some FD's have changed, callbacks should get called. My question is, why callbacks dont get called even if FD's have change?


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)


#Well obviosly none of the monitored sockets had traffic in the directions that
#were checked.

If there is no traffic, then why did select return before timeout?




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


#All requests consist of parts sending and parts receiving. You have to send
#data and receive data and during different times libcurl will use either, or
#both. That's why the _fdset() function is provided!


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


#FD_ISSET() is the macro you use to check for a specific file decsription in
#one of the fds sets when select() returns.
I think I cannot use it here, since libcurl does not provide me raw socket that is used internally.

But if those are handles that libcurl manages for you, you really should not
bother or even try to care about such details.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to