/////////////////////////////////////////////////////////////////////////////
-// Name: common/ftp.cpp
+// Name: src/common/ftp.cpp
// Purpose: FTP protocol
// Author: Guilhem Lavaux
// Modified by: Mark Johnson, wxWindows@mj10777.de
return true;
}
-bool wxFTP::Connect(const wxString& host)
+bool wxFTP::Connect(const wxString& host, unsigned short port)
{
wxIPV4address addr;
addr.Hostname(host);
- addr.Service(wxT("ftp"));
+
+ if ( port )
+ addr.Service(port);
+ else if (!addr.Service(wxT("ftp")))
+ addr.Service(21);
return Connect(addr);
}
{
m_lastError = wxPROTO_CONNERR;
wxLogError(_("Timeout while waiting for FTP server to connect, try passive mode."));
- delete sock;
- sock = NULL;
+ wxDELETE(sock);
}
else
{
addrNew.Service(0); // pick an open port number.
wxSocketServer *sockSrv = new wxSocketServer(addrNew);
- if (!sockSrv->Ok())
+ if (!sockSrv->IsOk())
{
- // We use Ok() here to see if everything is ok
+ // We use IsOk() here to see if everything is ok
m_lastError = wxPROTO_PROTERR;
delete sockSrv;
return NULL;
// when checking the result, the stream will
// almost always show an error, even if the file was
- // properly transfered, thus, lets just grab the result
+ // properly transfered, thus, let's just grab the result
// we are looking for "226 transfer completed"
char code = m_ftp->GetResult();