wxFTP ftp;
ftp.SetTransferMode(wxFTP::ASCII);
ftp.SetUser("anonymous");
ftp.SetPassword("[email protected]");
if ( !ftp.Connect(wxT("192.168.1.4")) ) {
wxLogError(wxT("Nie mogę połączyć się z serwerem"));
return;
};
ftp.Pwd();
ftp.ChDir("/");
wxInputStream *in = ftp.GetInputStream(wxT("version.txt"));
if (!in) {
wxLogError(wxT("Nie mogę pobrać aktualizacji"));
} else {
//in->GetSize() daje mi 0
//ftp.GetFileSize(wxT("version.txt")), daje -1
wxMessageBox(wxString::Format("Rozmiar w strumieniu %i %i",in->GetSize(),ftp.GetFileSize(wxT("version.txt")) ));
size_t size = in->GetSize();
char *data = new char[size];
if (!in->Read(data, size)) {
wxLogError(wxT("Błąd odczytu ze strumienia"));
} else {
Do serwera się łączę, ale otrzymuję:
Błąd odczytu ze strumienia
Failed to set FTP transfer mode to ASCII.
The FTP server doesen't support passive mode.
Natomiast nie mam problemów aby pobać ten plik przy pomocy klienta FileZilla
--- log z serwera po połączeniu do niego z klienta FileZilla
(000058) 2010-05-22 1715 - (not logged in) (192.168.1.4)> Connected, sending welcome message...
(000058) 2010-05-22 1715 - (not logged in) (192.168.1.4)> 220 Prywatny serwer FTP
(000058) 2010-05-22 1715 - (not logged in) (192.168.1.4)> USER anonymous
(000058) 2010-05-22 1715 - (not logged in) (192.168.1.4)> 331 Password required for anonymous
(000058) 2010-05-22 1715 - (not logged in) (192.168.1.4)> PASS **************
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> 230 Logged on
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> CWD /
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> 250 CWD successful. "/" is current directory.
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> PWD
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> 257 "/" is current directory.
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> TYPE A
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> 200 Type set to A
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> PASV
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> 227 Entering Passive Mode (192,168,1,4,9,108)
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> RETR version.txt
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> 150 Connection accepted
(000058) 2010-05-22 1715 - anonymous (192.168.1.4)> 226 Transfer OK
(000057) 2010-05-22 1719 - anonymous (192.168.1.4)> disconnected.
--- log z serwera po połączeniu do niego z mojego programu
(000052) 2010-05-22 1736 - (not logged in) (192.168.1.4)> Connected, sending welcome message...
(000052) 2010-05-22 1736 - (not logged in) (192.168.1.4)> 220 Prywatny serwer FTP
(000052) 2010-05-22 1736 - (not logged in) (192.168.1.4)> USER anonymous
(000052) 2010-05-22 1736 - (not logged in) (192.168.1.4)> 331 Password required for anonymous
(000052) 2010-05-22 1736 - (not logged in) (192.168.1.4)> PASS ************************
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> 230 Logged on
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> PWD
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> 257 "/" is current directory.
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> CWD /
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> 250 CWD successful. "/" is current directory.
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> TYPE I
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> 200 Type set to I
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> PASV
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> 227 Entering Passive Mode (192,168,1,4,9,78)
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> RETR version.txt
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> 150 Connection accepted
(000052) 2010-05-22 1736 - anonymous (192.168.1.4)> 226 Transfer OK
(000052) 2010-05-22 1738 - anonymous (192.168.1.4)> ABOR
(000052) 2010-05-22 1738 - anonymous (192.168.1.4)> 226 ABOR command successful
(000052) 2010-05-22 1738 - anonymous (192.168.1.4)> QUIT
(000052) 2010-05-22 1738 - anonymous (192.168.1.4)> 221 Goodbye
(000052) 2010-05-22 1738 - anonymous (192.168.1.4)> disconnected.