cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: FTP upload issue

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 2 Nov 2016 17:41:02 +0100

On Tue, Nov 01, 2016 at 06:37:36PM -0700, Carlos Rimola wrote:
> I am a relative newbie to libcurl and I hope someone can help me with an issue
> I am having performing FTP uploads. First, some background:
>
> 1) I need to use the multi-interface.
>
> 2) I started with the ftpupload.c example. I modified it to add mcurl_init, add
> the easy_handle, etc. That all works fine. I called that ftpuploadm.c. It's
> pretty much ftpupload.c with minor "multi" modifications.
>
> 3) The data I need to upload I have no control over and is part of large
> embedded system. The data comes to me via a "channel" in 256 byte chunks.
> Therefore the parameter I pass to my read_callback is not a file descriptor.
>
> 4) I have tried passing the data pointer and length in a data structure up to
> the read_callback. I have also tried reading the "channel" within the callback.
>
>
> The problem I see is that data on the channel is always ready (available) and
> the first 10 times I call curl_multi_perform. My read_callback is not invoked.

If it's not invoked, then it's not time to send the data to the other side yet.

> I turned the VERBOSE option on and I can see what is going but have tried a
> number of things and I can't avoid the condition. 

I don't who to what "the condition" refers.

> What VERBOSE shows is that during those first 10 calls to curl_multi_perform,
> the FTP control socket connection is being established (I assume the data
> socket as well). It is only when it reaches its end (I see " < 150 Ok to send
> data" that my callback is then called consistently and successfully on each
> call to curl_multi_perform. However, I end up with a transfer that is 2560
> bytes short (256 x 10).

libcurl will send whatever data you pass to it. Have you set the correct data
length with CURLOPT_INFILESIZE_LARGE? Are you returning the correct value from
the read data callback? Are you setting the correct binary vs. ASCII mode for
the URL?

> Is there any way to establish the control and data connections and know they
> are established so that calling curl_multi_perform will invoke my read_callback
> (when the connection is established, logged in and all is ready)?

libcurl will invoke the read callback function when it's read to send data.
There is no need for the application to know where libcurl is in its transfer
state machine; just pass data when it's requested and libcurl will handle the
rest.

>>> Dan
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-11-02