Всем привет! Как это можно сделать? Я могу только получить ip, заданный для локальной сети... А как получить свой реальный интернетный ip?
Спасибо!
{
...
m_pHttp = new QHttp();
QDialog::connect(m_pHttp, SIGNAL(done(bool)), this, SLOT(OnReadyRead()));
m_pHttp->setHost("www.grio.ru");
m_pHttp->get(QUrl::toPercentEncoding("/myip.php"));
...
}
void CDifferentSettingsDialog::OnReadyRead()
{
QMessageBox::information(this, m_pMessage->GetMessage(eHeader), m_pHttp->readAll());
}
m_pHttp->get("/myip.php");
CDifferentSettingsDialog::CDifferentSettingsDialog(...)
{
...
m_pHttp = new QHttp();
QDialog::connect(m_pHttp, SIGNAL(done(bool)), this, SLOT(OnReadyRead()));
m_pHttp->setHost("2ip.ru");
m_pHttp->get("/index.php");
...
}
void CDifferentSettingsDialog::OnReadyRead()
{
m_sCurrentDynIP = "";
const QString sText = m_pHttp->readAll();
const QRegExp oRegExp("((1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})\\.){3,3}(1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})");
const int n = sText.indexOf(oRegExp);
if (n == -1) return;
m_sCurrentDynIP = sText.mid(n, 15); //255.255.255.255
const int nLength = m_sCurrentDynIP.length();
for (int i = 0; i < nLength; ++i)
{
const QChar sSymbol = m_sCurrentDynIP.at(i);
if (sSymbol.isDigit() || sSymbol == '.') continue;
m_sCurrentDynIP.replace(i, 1, " ");
}
m_sCurrentDynIP = m_sCurrentDynIP.trimmed();
}
m_sCurrentDynIP = sText.mid(n, 15); //255.255.255.255
const int nLength = m_sCurrentDynIP.length();
for (int i = 0; i < nLength; ++i)
{
const QChar sSymbol = m_sCurrentDynIP.at(i);
if (sSymbol.isDigit() || sSymbol == '.') continue;
m_sCurrentDynIP.replace(i, 1, " ");
}
m_sCurrentDynIP = m_sCurrentDynIP.trimmed();
m_sCurrentDynIP = sText.mid(n, 15); //255.255.255.255
const int nLength = m_sCurrentDynIP.length();