cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Use read/write with same curl handle.

From: Nilesh <nilesh_at_kenati.com>
Date: Tue, 28 Feb 2006 20:01:31 +0530

In fact while DEBEG trace function given in example code in file
multi-debugcallback.c, curl_infotype is not set to CURLINFO_DATA_IN.
Shall I assum that mean no data has come ?

--
Nilesh
Nilesh wrote:
> Thanks for taking it ahead
> see my comments inline,
>
> Daniel Stenberg wrote:
>
>> On Tue, 28 Feb 2006, Nilesh wrote:
>>
>>> Can I use same curl handle to send and receive data ?
>>
>>
>> Yes.
>>
>>> -- Using multi_perform and select to check if data is available to 
>>> send/recieve.
>>>
>>> Problem is that flow is coming to default case of switch, which 
>>> tells some data has come.
>>
>>
>> What flow is coming to what "default case" ?
>
>     The flow is basically as follows where the default case indicate 
> there is data available to send/receive
>     curl_multi_perform(multi_handle, &still_running);
> //  while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, 
> &still_running));
>
>   /* Now need to wait for SendInform response */
>   while(still_running)
>   {
>     struct timeval timeout;
>
>     fd_set fdread;
>     fd_set fdwrite;
>     fd_set fdexcep;
>     int maxfd;
>     int timed_out = 0;
>
>     FD_ZERO(&fdread);
>     FD_ZERO(&fdwrite);
>     FD_ZERO(&fdexcep);
>
>     /* set a suitable timeout to play around with */
>     timeout.tv_sec = waitTime;
>     timeout.tv_usec = 0;
>
>     while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, 
> &still_running))
>     {
>       printf("Insite while, calling curl_multi_perform 
> [still_running-%d]\n", still_running);
>     }
>
>     /** get file descriptors from the transfers */
>     curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
>
>     printf("Wait here for [%d] seconds\n", waitTime);
>
>     rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
>
>     switch(rc)
>     {
>       case -1:
>         /* select error */
>         break;
>       case 0:
>         /* timeout, do something else */
>         printf("Select Timeout happened\n");
>         timed_out = 1;
>         break;
>       default:
>         /* one or more of curl's file descriptors say there's data to read
>         or write */
>         printf("Have some data to process\n");
>         while(CURLM_CALL_MULTI_PERFORM == 
> curl_multi_perform(multi_handle, &still_running));
>        break;
>     }*
>    
>     Timeout in my case is 120 Seconds.
>    
>
>>
>>> While DEBUGIng I am getting HTTP header details which I have 
>>> received with vaid content length, but it doesn't display data.
>>
>>
>> Are you saying libcurl says the transfer is complete after only the 
>> headers have been transferred? I find that hard to believe.
>
>  
>    This what I see when I enable debug support for curl. ( i am using 
> same function callback given in example directory )
>    I have additionaly using header_callback function also which prints 
> custome message give below ( "Incoming header has come" )  
>   
>  *   Have some data to process
> <= Recv header, 17 bytes (0x11)
> 0000: HTTP/1.1 200 OK
> Incoming header has come [HTTP/1.1 200 OK
> ]
> <= Recv header, 27 bytes (0x1b)
> 0000: Server: Apache-Coyote/1.1
> Incoming header has come [Server: Apache-Coyote/1.1
> ]
> <= Recv header, 72 bytes (0x48)
> 0000: Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*
> 0040: ; q=.2
> Incoming header has come [Accept: text/xml, text/html, image/gif, 
> image/jpeg, *; q=.2, */*; q=.2
> ]
> <= Recv header, 16 bytes (0x10)
> 0000: SOAPAction: ""
> Incoming header has come [SOAPAction: ""
> ]
> <= Recv header, 38 bytes (0x26)
> 0000: Content-Type: text/xml;charset=utf-8
> Incoming header has come [Content-Type: text/xml;charset=utf-8
> ]
> <= Recv header, 21 bytes (0x15)
> 0000: Content-Length: 484
> Incoming header has come [Content-Length: 484
> ]
> <= Recv header, 37 bytes (0x25)
> 0000: Date: Tue, 28 Feb 2006 14:14:27 GMT
> Incoming header has come [Date: Tue, 28 Feb 2006 14:14:27 GMT
> ]
> Incoming header has come [
> ]*
>
> PS : I am using write_callback similar to what has been given in 
> getinmemory.c ( example code)
>    
> Even I tried using default write callback which will write to FILE* 
> stream, which writting nothing in specified file .
>
>>
>>> I have also put debug printf in write_callback function to printf 
>>> received data, which doesn't really get printed.
>>
>>
>> And you are sure you keep looping and calling the *perform() function 
>> as long as the transfer is still alive?
>
>     Yes I do that. I have posted the loop above.
>
>
Received on 2006-02-28