curl-library
Libcurl closing socket when socket is closed by server already
Date: Fri, 8 Nov 2013 06:01:56 +0800 (SGT)
http://curl.haxx.se/mail/tracker-2005-11/0013.html
I followed this thread and exactly this is the issue I am currently facing with Libcurl not immediately closing the socket when server sends FIN packet
I do not want to close and open the connection everytime as this might be resource consuming for server to do SSL handshake everytime
To overcome the issue, I referred to the following post which talked about using SSL_SEEK in the getinfo of LASTSOCKET interface.
I have a solution which is working for me now. But still not sure if I have effectively made a choice.
This is what I am doing now and need your feedback about the same
1. At the start of application I create a pool of curl handle with easy_init()
2. Since I use ssl I have implemented the lock and unlock methods.
3. I pick up an handle form the available pool and use it for the POST request.
4. At the end of perform I use “easy_reset()” with the intention to re-use the socket if further request needs to be send.
5. When the second request comes before setting the options I use the LASTSOCKET API on the curlHandle to see if it returns me BAD SOCKET.
a. If it returns a BAD SOCKET I immediately call “easy_cleanup” and then call “easy_init()”. Then further continue with my work.
b. If it returns valid then I use the same handle and continue with the transfer.
Before doing “Step 5” the experience I faced was “hang” and it waited till it timed out naturally.
Any thoughts?
Thanks for reading the post your feedback will really help me.
____________________
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-11-07