Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@15616 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2007-09-13 15:25:14 +00:00
parent 5a016b1643
commit 3fde240c2e
2 changed files with 52 additions and 31 deletions

View File

@ -1232,6 +1232,12 @@ void CampoWizardPage8::OnSrvClick(wxCommandEvent& e)
bool CampoWizardPage8::TransferDataToWindow() bool CampoWizardPage8::TransferDataToWindow()
{ {
const wxString strSrvAuth = GetWizard().GetSrvAuth();
if (!strSrvAuth.IsEmpty())
{
Set(808, strSrvAuth);
FindWindowById(808)->Disable();
}
return true; return true;
} }

View File

@ -162,16 +162,22 @@ static unsigned short InquireServer(const wxString& strSrvName, int& year, const
wxSocketClient sc; wxSocketClient sc;
sc.SetTimeout(2); sc.SetTimeout(2);
sc.SetFlags(sc.GetFlags() | wxSOCKET_REUSEADDR);
if (!sc.Connect(ip)) //il computer remoto risponde ma il server no (non c'e' o e' spento) if (!sc.Connect(ip)) //il computer remoto risponde ma il server no (non c'e' o e' spento)
{ {
if (bMsg) if (bMsg)
ErrorBox("Il server specificato non e' raggiungibile!"); {
wxString strMsg;
strMsg << "Il server " << strSrvName << " non e' raggiungibile!";
ErrorBox(strMsg);
}
return 0xFFFF; return 0xFFFF;
} }
unsigned short serno = InquireSocketNumber(sc, "DongleNumber()"); unsigned short serno = InquireSocketNumber(sc, "DongleNumber()");
year = InquireSocketNumber(sc, "DongleYear()"); year = InquireSocketNumber(sc, "DongleYear()");
sc.Destroy();
return serno; return serno;
} }
@ -191,39 +197,48 @@ unsigned short ServerLogin(int& year, wxString& strSrvName)
if (strMyIP.Len() > 7) if (strMyIP.Len() > 7)
{ {
wxSocketClient sc[256]; const unsigned short MaxSck = 6;
for (int i = 0; i < 256; i++) for (int j = 3; j < 256 && serno == 0xFFFF; j += MaxSck)
{
wxSocketClient sc[MaxSck];
wxIPV4address ipRemote[MaxSck];
for (int i = 0; i < MaxSck; i++)
{
const int n = i+j;
if (n < 256)
{ {
//deve sostituire l'ultima cifra dell'IP con tutti i numeri che vanno da 0 a 255 alla ricerca del server //deve sostituire l'ultima cifra dell'IP con tutti i numeri che vanno da 0 a 255 alla ricerca del server
wxString strSrvIP = strMyIP.BeforeLast('.'); wxString strSrvIP = strMyIP.BeforeLast('.');
strSrvIP << "." << i; strSrvIP << "." << n; //ip del computer remoto
wxIPV4address ipRemote; if (strSrvIP == strMyIP)
if (ipRemote.Hostname(strSrvIP) && ipRemote.Service("1883")) continue;
if (ipRemote[i].Hostname(strSrvIP) && ipRemote[i].Service("1883"))
{ {
sc[i].SetTimeout(2); sc[i].SetTimeout(2);
sc[i].Connect(ipRemote, false); sc[i].SetFlags(sc[i].GetFlags() | wxSOCKET_REUSEADDR);
sc[i].Connect(ipRemote[i], false);
} }
} }
wxSleep(2); }
for (int i = 0; i < 256; i++) wxMilliSleep(100);
for (int i = 0; i < MaxSck; i++)
{ {
sc[i].WaitOnConnect(0, 10); sc[i].WaitOnConnect(0, 1);
if (sc[i].IsConnected()) if (sc[i].IsConnected())
{ {
wxIPV4address ipRemote; sc[i].GetPeer(ipRemote[i]);
sc[i].GetPeer(ipRemote); strSrvName = ipRemote[i].Hostname();
strSrvName = ipRemote.Hostname();
serno = InquireSocketNumber(sc[i], "DongleNumber()"); serno = InquireSocketNumber(sc[i], "DongleNumber()");
year = InquireSocketNumber(sc[i], "DongleYear()"); year = InquireSocketNumber(sc[i], "DongleYear()");
if (year > 0) if (year > 0)
break; break;
} }
} } //for (inti =0...
for (int i = 0; i < MaxSck; i++)
for (int i = 0; i < 256; i++)
sc[i].Destroy(); sc[i].Destroy();
} } //for(int j=0...
} } //if(strMyIP.Len()...
} //if(strSrvName.Is...
else else
serno = InquireServer(strSrvName, year, true); serno = InquireServer(strSrvName, year, true);