cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: uploaded file is of 0 bytes using FTP-SSL with libcurl

From: Tor Arntsen <tor_at_spacetec.no>
Date: Mon, 23 Jan 2006 16:03:00 +0100

>On Fri, 20 Jan 2006, Michael Jahn wrote:
>
>> I think, the socket for uploading is closed to fast. It seems that there is
>> data on the port waiting for transmitting but libcurl closes the socket to
>> fast. So the data is discarded. If there is less then 4kbytes data to send
>> the resulting filesize on the server will be 0.

tcp/ip doesn't work that way. The application does not know when the
data written to the socket is actually transmitted over the wire (unless
you implement your own acknowledge protocol at the application level),
and when you close your socket descriptor the unwritten data on your
socket will still be transmitted. You can test this easily by using
a transmitter- and receiver application and let the receiver be very
slow at reading (or unplug the cable or whatever). Monitor with netstat
and see the Send-Q data still being pumped out after the transmitter is
finished. The socket will typically be in FIN_WAIT1 but the data is not
discarded. When Send-Q is empty it goes to FIN_WAIT2 until the receiver
has cleared out its own Recv-Q, then closing.

-Tor
Received on 2006-01-23