cURL / Mailing Lists / curl-library / Single Mail


Question regarding FTPS with libcurl CURLOPT_RESUME_FROM option

From: Satish Mittal <>
Date: Wed, 25 Jun 2008 14:49:22 +0530


I am using libcurl easy interface to implement FTPS download/upload
in my multi-threaded application (that has to run on Windows/*NIX
platforms). In addition, I also need to provide resiliency support within my
application (i.e. if the connection to remote FTPS server breaks during data
transfer, then the transfer should resume from the previous state properly).

It is working fine in case of normal download/upload, but there seems to be
an issue in upload case if the connection breaks. I get data to be uploaded
filled in my buffers in-memory from other app threads, and I am copying
these data buffers inside curl writecallback. To achieve resiliency, I have
set CURLOPT_RESUME_FROM as -1, so that libcurl resumes appending data at the
end of remote file. However it seems that in case of a new connection (when
this CURLOPT_RESUME_FROM option is set) libcurl first calculates the SIZE
command to calculate the actual size of remote file, and then goes into a
loop ignoring that much data from my local buffers, before it starts
appending data. Is this understanding correct?

This would mean that I would have to cache all the data I have written
previously so that I could then pass it all over again to handle resume
cases. However that is not possible since the data size could potentially go
to couple of GBs, and I will have to settle for only some fixed size cache.
Is there a way I could know the size of the remote file in the resume phase,
so that I could deterministically know whether my cache can replay the data
correctly or not. If not, that would at least help me to fail the
application correctly.


"The happiest of people donĀ“t necessarily have the best of everything, they
just make the most of everything that comes along their way."
Received on 2008-06-25