+void wxFTP::SetDefaultTimeout(wxUint32 Value)
+{
+ m_uiDefaultTimeout = Value;
+ SetTimeout(Value); // sets it for this socket
+}
+
+
+wxSocketBase *wxFTP::GetPort()
+{
+ /*
+ PASSIVE: Client sends a "PASV" to the server. The server responds with
+ an address and port number which it will be listening on. Then
+ the client connects to the server at the specified address and
+ port.
+
+ ACTIVE: Client sends the server a PORT command which includes an
+ address and port number which the client will be listening on.
+ The server then connects to the client at that address and
+ port.
+ */
+
+ wxSocketBase *socket = m_bPassive ? GetPassivePort() : GetActivePort();
+ if ( !socket )
+ {
+ m_bEncounteredError = true;
+ return NULL;
+ }
+
+ // Now set the time for the new socket to the default or user selected
+ // timeout period
+ socket->SetTimeout(m_uiDefaultTimeout);
+
+ return socket;
+}
+
+wxSocketBase *wxFTP::AcceptIfActive(wxSocketBase *sock)
+{
+ if ( m_bPassive )
+ return sock;
+
+ // now wait for a connection from server
+ wxSocketServer *sockSrv = (wxSocketServer *)sock;
+ if ( !sockSrv->WaitForAccept() )
+ {
+ m_lastError = wxPROTO_CONNERR;
+ wxLogError(_("Timeout while waiting for FTP server to connect, try passive mode."));
+ delete sock;
+ sock = NULL;
+ }
+ else
+ {
+ sock = sockSrv->Accept(true);
+ delete sockSrv;
+ }
+
+ return sock;
+}
+
+wxString wxFTP::GetPortCmdArgument(const wxIPV4address& addrLocal,
+ const wxIPV4address& addrNew)
+{
+ // Just fills in the return value with the local IP
+ // address of the current socket. Also it fill in the
+ // PORT which the client will be listening on
+
+ wxString addrIP = addrLocal.IPAddress();
+ int portNew = addrNew.Service();
+
+ // We need to break the PORT number in bytes
+ addrIP.Replace(_T("."), _T(","));
+ addrIP << _T(',')
+ << wxString::Format(_T("%d"), portNew >> 8) << _T(',')
+ << wxString::Format(_T("%d"), portNew & 0xff);
+
+ // Now we have a value like "10,0,0,1,5,23"
+ return addrIP;
+}
+
+wxSocketBase *wxFTP::GetActivePort()