title: C++ Libcurl: curl_easy_perform returned error code 28 when transferring files from linux system to windows remote system
body: <p>I’m using libcurl 7.37.0 in my C++ project to communicate with remote by FTP protocol.</p>
  
  <p>below is the code.</p>
  
  <pre><code>curl_easy_setopt(CurlSessionHandle, CURLOPT_URL, remoteFileUrl);
  curl_easy_setopt(CurlSessionHandle, CURLOPT_UPLOAD, ON);
  
  // Set the input local file handle
  curl_easy_setopt(CurlSessionHandle, CURLOPT_READDATA, localFileHandle);
  
  // Set on/off all wanted options
  // Enable ftp data connection
  curl_easy_setopt(CurlSessionHandle, CURLOPT_NOBODY, OFF);
  
  // Create missing directory into FTP path
  curl_easy_setopt(CurlSessionHandle, CURLOPT_FTP_CREATE_MISSING_DIRS , ON) ;
  
  // Set the progress function, in order to check the stop transfer request
  curl_easy_setopt(CurlSessionHandle, CURLOPT_NOPROGRESS, OFF);
  curl_easy_setopt(CurlSessionHandle, CURLOPT_PROGRESSFUNCTION, progressCb);
  curl_easy_setopt(CurlSessionHandle, CURLOPT_PROGRESSDATA, this);
  
  CURLcode Result = curl_easy_perform(CurlSessionHandle);
  </code></pre>
  
  <p>many times i have observed uploading of files is failing due to <strong>error code 28</strong>.</p>
  
  <p><strong>CURLE_OPERATION_TIMEDOUT (28)</strong>
  Operation timeout. The specified time-out period was reached according to the conditions.</p>
  
  <p>i didn't set any timeout in the code, after doing a lot of search i came to know we can use <strong>CURLOPT_TIMEOUT</strong> to set the timeout value, by default it's value is 0 where it doesn't timeout until it finishes the respective operation, in my case i performed file upload operation.</p>
  
  <p>after going through the wireshark logs, i have observed that when data transfer is initiated from port 20, i see libcurl sends <strong>[FIN,ACK]</strong> without any known reason to port 21, because of that remote sends response code 426(transfer aborted) to libcurl and it returns 28 error code to application. </p>
  
  <p>Please check the image which has wireshark traces.</p>
  
  <p>Source IP: 18 is Linux server &amp; Destination IP: 36 is Windows remote system</p>
  
  <p><a href="https://i.stack.imgur.com/5ipcI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ipcI.png" alt="enter image description here"></a></p>
  
  <p>This problem is happening randomly.
  Could anyone know the reason &amp; a way to avoid this problem.</p>