@@ -26,13 +26,15 @@ quint32 ipv4str_to_int(const QString& ipstr)
|
||||
}
|
||||
}
|
||||
|
||||
bool Ping(QString strPingIP)
|
||||
bool Ping(QString strPingIP,qint16 timeout)
|
||||
{
|
||||
QProcess pingProcess;
|
||||
QString strArg = "ping " + strPingIP + " -n 1 -i 2";
|
||||
QString strArg = "ping " + strPingIP + " -n 2 -w "+QString("%1").arg(timeout);// + " -n 1 -i 2";
|
||||
qDebug()<<strArg;
|
||||
pingProcess.start(strArg, QIODevice::ReadOnly);
|
||||
pingProcess.waitForFinished(-1);
|
||||
QString p_stdout = QString::fromLocal8Bit(pingProcess.readAllStandardOutput());
|
||||
qDebug()<<p_stdout;
|
||||
return p_stdout.contains("TTL=");
|
||||
}
|
||||
|
||||
@@ -48,7 +50,7 @@ void trytryping::run()
|
||||
|
||||
QString ip=this->ipstr;
|
||||
|
||||
if(Ping(ip))
|
||||
if(Ping(ip,this->timeout))
|
||||
{
|
||||
emit connect_ok(ip);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user