curl-library
Persistant Connectins testing
Date: Tue, 27 Nov 2001 12:15:02 +0200
Hello,
thanks for your previous immediate response.
I am trying now to test the persistant connections feature. So, I wrote
the following simple program (a copy of your example):
_______________________________________________________________________________________________
//Common includes
#include <iostream.h>
//CURL includes
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
main(int argc, char *argv[])
{
CURL *curl;
CURLcode res;
FILE *ftpfile, *ftpls;
/* local file name to store the file as */
ftpfile = fopen("readme.txt", "wb"); /* b is binary for win */
ftpls = fopen("ftpls.txt", "wb");
struct curl_slist* list=NULL;
list = curl_slist_append(list, "cwd usr");
curl = curl_easy_init();
if(curl) {
cout << "TRY TO CONNECT" << endl;
curl_easy_setopt(curl, CURLOPT_URL, "ftp://myhost/readme..txt");
curl_easy_setopt(curl, CURLOPT_FILE, ftpfile);
curl_easy_setopt(curl, CURLOPT_USERPWD, "dimitris:dimitris");
// curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, 1);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
cout << "Before perform" << endl;
res = curl_easy_perform(curl);
cout << "Error: " << res << endl;
cout << list->data << endl;
curl_easy_setopt(curl, CURLOPT_URL, "ftp://myhost");
curl_easy_setopt(curl, CURLOPT_FILE, ftpls);
curl_easy_setopt(curl, CURLOPT_USERPWD, "dimitris:dimitris");
curl_easy_setopt(curl, CURLOPT_QUOTE, list);
res = curl_easy_perform(curl);
cout << "Error: " << res << endl;
curl_slist_free_all(list);
/* always cleanup */
curl_easy_cleanup(curl);
}
fclose(ftpfile); /* close the local file */
fclose(ftpls);
return 0;
}
__________________________________________________________________________________________
When I execute the above, it crashes at the first call of
"curl_easy_perform". I debugged with dbx and I found that it crashes
inside the "Curl_getaddrinfo", at line 831 of the "ftp.c" :
831: if(gethostbyaddr_r((char *) &address,
sizeof(address), AF_INET,
(struct hostent *)hostent_buf,
hostent_buf + sizeof(*answer)))
(DBX output)
0 ftp_pasv_verbose(conn = 0x14003f800, addr = 0x14007e030, newhost =
0x11fffeeb8 = "146.124.12.49", port = 58599) ["ftp.c":821,
0x3ffbffed2b8]
1 ftp_use_pasv(conn = 0x14003f800) ["ftp.c":1351, 0x3ffbffedb58]
2 ftp_perform(conn = 0x14003f800) ["ftp.c":1477, 0x3ffbffede4c]
3 Curl_ftp(conn = 0x14003f800) ["ftp.c":1898, 0x3ffbffeeaa0]
4 Curl_do(conn = 0x14003f800) ["url.c":2164, 0x3ffbfff2bd4]
5 Curl_perform(data = 0x140053040) ["transfer.c":927,
0x3ffbfffc178]
6 curl_easy_perform(curl = 0x140053040) ["easy.c":233,
0x3ffbfffcbac]
7 main(argc = 1, argv = 0x11ffff0e8) ["ftp_application.cxx":48,
0x1200020e4]
The strangest thing is that your example runs without a problem. :-!
Thanks,
Dimitris
Received on 2001-11-27