cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: how to get socket fd from libcurl in curl multi interface.

From: venkataragavan vijayakumar <venkataragavan.v_at_gmail.com>
Date: Wed, 28 Sep 2011 17:06:01 +0530

Hi,

Thanks for the support.

Our requirement is using single thread/process calling the libcurl API's to
do HTTP POST and getting response from the server by asynchronous way.
Since curl_easy_perform is a blocking call, we went to multi_perform

currenlty we have gone half way by,

1. creating easy handle , using easy_setopt setting the POST requirements.
2. Then adding the *easy handle* to *multi handle* . and execute the *multi
perform* until it finishes the operation.
3. But we are struggling to get the clue how to get the response from the
server through libcurl.

Whether we need to pass the socket fd to libcurl, If so , how to do that?
Any particular API is for that. Please give us that.

FD_SET is given by the multi_fdset API , we will do the select(),after that
we will call the curl_multi_socket_action(), but it needs the socket fd.

Please Help us.

Thanks,
Venkat.

On Tue, Sep 27, 2011 at 8:10 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Tue, 27 Sep 2011, venkataragavan vijayakumar wrote:
>
> we are using curl multi interface. we want to read the data from the fd.
>>
>
> I would really really urge you to reconsider that wish. In 101 cases out of
> a 100 that's the wrong idea and is due to a misunderstanding of how libcurl
> works.
>
>
> we have got the fdset from the
>> CURLMcode curl_multi_fdset(CURLM *multi_handle, fd_set *read_fd_set,
>> fd_set *write_fd_set, fd_set *exc_fd_set, int *max_fd);
>>
>> After this we have used select() call.
>>
>> But we need socket fd, so that we will do FD_ISSET() and then read the
>> data from the FD.
>>
>
> You can't even know what the sockets libcurl uses are for, reading from it
> is making assumptions of functionality that libcurl will not guarantee and
> is likely to break when circumstances chance.
>
>
> I have seen curl_multi_socket_action() API, it also needs the socket fd.
>>
>
> Not really. You need to tell libcurl what sockets to act on, yes, but
> libcurl has already before that told you which sockets it works on and what
> it expects you to wait for on each of those sockets.
>
> See the hiperfifo example for how the multi_socket API works:
>
> http://curl.haxx.se/libcurl/c/**hiperfifo.html<http://curl.haxx.se/libcurl/c/hiperfifo.html>
>
> I realize I should add a section to the libcurl-multi.3 man page that
> explains the basic idea of the multi_socket API...
>
> --
>
> / daniel.haxx.se
> ------------------------------**------------------------------**-------
> List admin: http://cool.haxx.se/list/**listinfo/curl-library<http://cool.haxx.se/list/listinfo/curl-library>
> Etiquette: http://curl.haxx.se/mail/**etiquette.html<http://curl.haxx.se/mail/etiquette.html>
>

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