cURL / Mailing Lists / curl-library / Single Mail

curl-library

Using CURLOPT_CONNECT_ONLY option in multi interface

From: Gökhan Şengün <gokhansengun_at_gmail.com>
Date: Thu, 13 Oct 2011 16:37:20 +0300

Hi Folks,

I am trying to setup an application capable of handling multiple FTP
transfers concurrently. My thread --driving the libcurl-- is fed with FTP
commands by another thread.

I am using curl_multi_fdset and curl_multi_timeout functions with
curl_multi_perform to be able to use "select" call. If the processing of a
command in the multi interface is finished, I expect to understand it using
curl_multi_info_read function. This works pretty much OK except one issue.

I would like to use CURLOPT_CONNECT_ONLY option and still be able to see if
connecting to FTP server is finished with curl_multi_info_read function so
that I can inform the other thread driving mine regarding the result of
CONNECT command.

Checking the code, I saw that in function multi_runsingle in file multi.c,
easy connection's state is set to CURLM_STATE_DONE instead of
CURLM_STATE_COMPLETED. When in this state, the easy handle is not considered
as "finished" and I can not get the result of my request with
curl_multi_info_read.

      if(data->set.connect_only) {
        /* keep connection open for application to use the socket */
        easy->easy_conn->bits.close = FALSE;
        *multistate(easy, CURLM_STATE_DONE);*
        easy->result = CURLE_OK;
        result = CURLM_OK;
      }

If I change the state in above code to CURLM_STATE_COMPLETED, I got the
behavior I really like to have.

Could you please tell if the current design is the intended behavior? Or I
am missing something here? And if there is any work-arounds?

Thanks.

-- 
if you can't find a good name for a function, then perhaps it is not a good
function to write

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