+ // 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()
+{
+ // we need an address to listen on
+ wxIPV4address addrNew, addrLocal;
+ GetLocal(addrLocal);
+ addrNew.AnyAddress();
+ addrNew.Service(0); // pick an open port number.
+
+ wxSocketServer *sockSrv = new wxSocketServer(addrNew);
+ if (!sockSrv->Ok())
+ {
+ // We use Ok() here to see if everything is ok
+ m_lastError = wxPROTO_PROTERR;
+ delete sockSrv;