I'm using libcurl to upload files to a remote ftp server. I would like to make sure the server is ready to start receiving uploads before I actually start sending them (I can't upload a file for testing, have to know in advance if the ftp server is ready). Ideally I want to write a code which will login to the ftp server and change directory to the destination directory on the remote server. If this test passed I can assume the server is ready to receive files. I wrote the following code
curl_global_init(CURL_GLOBAL_ALL);
m_curl = curl_easy_init(); // Get a curl handle
if (!m_curl)
return -1;
curl_easy_setopt(m_curl, CURLOPT_USERNAME, "username");
curl_easy_setopt(m_curl, CURLOPT_PASSWORD, "password");
curl_easy_setopt(m_curl, CURLOPT_UPLOAD, 1L);
struct curl_slist* headerList = NULL;
headerList = curl_slist_append(headerList, "CWD directory");
curl_easy_setopt(m_curl, CURLOPT_URL, "ftp://192.168.1.2/");
curl_easy_setopt(m_curl, CURLOPT_POSTQUOTE, headerList);
CURLcode res = curl_easy_perform(m_curl);
if(res == CURLE_OK)
return 0;
else
return -1;
username and password are correct and directory exists under ftp root. I look in the network capture and it seems like after successful login my client requests "PWD" which passes fine but then it asks for the SIZE of directory but it gets 550 error, could not get file size. I then tried without the headerList, just the login, again login passes fine and after PWD request I get 500 OOPS, vsf_sysutil_recv_peek no data. Any idea how can I test the server, in a similar manner?