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:
parent
5a016b1643
commit
3fde240c2e
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,23 +162,29 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short ServerLogin(int& year, wxString& strSrvName)
|
unsigned short ServerLogin(int& year, wxString& strSrvName)
|
||||||
{
|
{
|
||||||
unsigned short serno = 0xFFFF;
|
unsigned short serno = 0xFFFF;
|
||||||
|
|
||||||
//se non specificato un nome/indirizzo di server, lo cerca tra i miei "cpu fratelli" in rete
|
//se non specificato un nome/indirizzo di server, lo cerca tra i miei "cpu fratelli" in rete
|
||||||
if (strSrvName.IsEmpty())
|
if (strSrvName.IsEmpty())
|
||||||
{
|
{
|
||||||
@ -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)
|
||||||
{
|
{
|
||||||
//deve sostituire l'ultima cifra dell'IP con tutti i numeri che vanno da 0 a 255 alla ricerca del server
|
wxSocketClient sc[MaxSck];
|
||||||
wxString strSrvIP = strMyIP.BeforeLast('.');
|
wxIPV4address ipRemote[MaxSck];
|
||||||
strSrvIP << "." << i;
|
for (int i = 0; i < MaxSck; i++)
|
||||||
wxIPV4address ipRemote;
|
|
||||||
if (ipRemote.Hostname(strSrvIP) && ipRemote.Service("1883"))
|
|
||||||
{
|
{
|
||||||
sc[i].SetTimeout(2);
|
const int n = i+j;
|
||||||
sc[i].Connect(ipRemote, false);
|
if (n < 256)
|
||||||
|
{
|
||||||
|
//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('.');
|
||||||
|
strSrvIP << "." << n; //ip del computer remoto
|
||||||
|
if (strSrvIP == strMyIP)
|
||||||
|
continue;
|
||||||
|
if (ipRemote[i].Hostname(strSrvIP) && ipRemote[i].Service("1883"))
|
||||||
|
{
|
||||||
|
sc[i].SetTimeout(2);
|
||||||
|
sc[i].SetFlags(sc[i].GetFlags() | wxSOCKET_REUSEADDR);
|
||||||
|
sc[i].Connect(ipRemote[i], false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
wxMilliSleep(100);
|
||||||
wxSleep(2);
|
for (int i = 0; i < MaxSck; i++)
|
||||||
for (int i = 0; i < 256; i++)
|
|
||||||
{
|
|
||||||
sc[i].WaitOnConnect(0, 10);
|
|
||||||
if (sc[i].IsConnected())
|
|
||||||
{
|
{
|
||||||
wxIPV4address ipRemote;
|
sc[i].WaitOnConnect(0, 1);
|
||||||
sc[i].GetPeer(ipRemote);
|
if (sc[i].IsConnected())
|
||||||
strSrvName = ipRemote.Hostname();
|
{
|
||||||
serno = InquireSocketNumber(sc[i], "DongleNumber()");
|
sc[i].GetPeer(ipRemote[i]);
|
||||||
year = InquireSocketNumber(sc[i], "DongleYear()");
|
strSrvName = ipRemote[i].Hostname();
|
||||||
if (year > 0)
|
serno = InquireSocketNumber(sc[i], "DongleNumber()");
|
||||||
break;
|
year = InquireSocketNumber(sc[i], "DongleYear()");
|
||||||
}
|
if (year > 0)
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
for (int i = 0; i < 256; i++)
|
} //for (inti =0...
|
||||||
sc[i].Destroy();
|
for (int i = 0; i < MaxSck; i++)
|
||||||
}
|
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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user