On Wed, 17 Jul 2013, Amit Pal wrote:
1) When from my client program I call curl_easy_perform() it uses normal send() on tcp socket to write data.
curl_easy_perform() does A LOT of things, but depending on your protocol of choice and what you've asked libcurl to do it may use send() (on its own) to send data over TCP. Yes.
2) then it changes state and pass fd to poll() to wait for response message.
Yes and no. It certainly handles incoming data, but for several protocols it handles both incoming and outgoing at the same time so then doesn't really "change state" for that. In fact, libcurl uses the same main code and state for almost all protocols' main transfer phase.
3) once response is received it stores it in some buffer.
libcurl receives data primarily, not "responses". With that I mean that mostly libcurl doesn't wait for a complete message that would be necessary to form a response.
But yes, when data is available it will read data into a buffer (and immediately sent off to the write callback).
4) state is again changed.
Right. libcurl will keep receiving (and sending) until there's nothing left to send and receive and then it will change state.
now after the transfer is success, is fd removed from poll(). After this transfer is done, I want to use the fd for some other purpose.
If the socket is still open after curl_easy_perform() returns, you can ask for it with curl_easy_getinfo's CURLINFO_LASTSOCKET option: http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html#CURLINFOLASTSOCKET
After this if some message comes on fd then will curl invoke poll() and hence read operation?
No. After curl_easy_perform() returns libcurl is done with the socket for now, and if you interfere with it outside of libcurl's fiddlings then it can't be re-used againt by libcurl since it no longer knows the state of it or what has been done there.
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
