c++ - Port range in the argument to PORT command -


suppose want connect ftp server, list root directory in active mode (via port command). i'm going use curl library.

seems, curl provides such capability. there's curlopt_ftpport option , official reference says, the port may optionally followed '-' specify port range.

    if (curl* curl = ::curl_easy_init())     {         guard.reset(curl, ::curl_easy_cleanup);          ::curl_easy_setopt(curl, curlopt_url, "ftp://10.0.0.162:21");         ::curl_easy_setopt(curl, curlopt_ftpport, "localhost:37000-38000");          curlcode retval = ::curl_easy_perform(curl);         if (retval != curle_ok)         {             throw networkerror(retval, ::curl_easy_strerror(retval));         }     }      ... 

but here's problem.

if first port in range not available, curl_easy_perform fails curle_ftp_port_failed.

edit

output in verbose mode:

* rebuilt url to: ftp://10.0.0.162:21/ * timeout on name lookup not supported *   trying 10.0.0.162... * connected 10.0.0.162 (10.0.0.162) port 21 (#0) < 220 eugee-server / banner > user anonymous < 331 anonymous access allowed, send identity (e-mail name) password. > pass ftp@example.com < 230-welcome ftp.eugeeserver < 230 user logged in. > pwd < 257 "/" current directory. * entry path '/' * socket failure: bad access * remembering in dir "" * connection #0 host 10.0.0.162 left intact 


Comments