cURL / Mailing Lists / curl-library / Single Mail

curl-library

re-use data connection for FTP transfers

From: Ashish Nigam <anigam_at_inmage.net>
Date: Wed, 19 Jan 2005 10:17:48 -0800

OK, I started a new thread this time :-)
I don't have problems with connections being broken and I am not using append due to unreliable connections.
I have to send about 100 MB of data to remote FTP server. I populate this data in memory at client side.
At remote server side, this data has to be present as part of a file.
It is not a good idea to create 100 MB of heap memory and then send all at once.
So I send in chunks of 5 MB or so. Now data in file should be in right order and all 100 MB data is part of one file, I
have to send data in append mode so that subsequent chunks are appended to the same file.

I use same Curl Handle for all transactions but for data transfers, for every chunk, it creates new data connection.
And I wanted to avoid the creation of new data connection for every chunk.

So I wanted to know if there is a way to tell Curl that even if I have send 5 MB of data at this time, there is more data ahead and re-use the same data connection.
I hope I am able to convey the correct scenario this time.

Thanks

On Tue, 18 Jan 2005, Ashish Nigam wrote:

(again: don't start a new thread by replying to an old mail)

> * Make transfers treated more carefully. We need a way to tell libcurl we
> have data to write

... This TODO item doesn't seem to be related to what you are doing.

> Now I am not using multi interface. So is it possible to do ?

Is what possible to do?

> I have to upload data from memory (not file) in chunks to remote file.

"in chunks" ? An FTP upload is a stream, there are no chunks on the wire. Or
are you referring to that you provide chunks to the libcurl callback function?

> At present, I have to set APPEND mode to true to send all data across in a
> file.

Using append does not make a transfer more reliable.

I figure you mean you have to use append since your connections break and you
re-issue the transfer multiple times.

I don't see how libcurl can do anything about that. If your connection is
unreliable, it will break. The only way to deal with broken connections is to
resume the previous transfer.

> Problem with this is that it creates a new data connection everytime and
> this can be a big overhead if I use small chunk and actual file size is very
> large.

Not only data connection, FTP uses two connections and if your connection to
the server breaks, both connections go down and you need to get both setup
again to continue the transfer.

> Is there any way to tell Curl to re-use data connection and then user can
> just feed-in data in that connection ?

Nope. FTP doesn't allow data connections to be re-used. A data connection is
by definition a newly setup connection and the only way to signal end-of-data
after a transfer is to close the data connection.

> I am using passive mode for data transfer.

It makes no differencet if you use active or passive mode in this regard.

--
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2005-01-19