句柄不足的bug

Signed-off-by: fong <wuwenfengmi@outlook.com>
This commit is contained in:
fong
2024-01-30 19:19:02 +08:00
parent 7ee3e2f832
commit 8fe554db19
3 changed files with 41 additions and 29 deletions
+19 -13
View File
@@ -39,17 +39,23 @@ void trytry::run()
emit try_one(1);
QString temp = QString("%1:%2").arg(ipstr).arg(ipint);
QTcpSocket m_socket;
m_socket.connectToHost(ipstr, ipint, QTcpSocket::ReadWrite);
if (m_socket.waitForConnected(timeout))
{
emit connect_ok(temp);
}
m_socket.disconnectFromHost();
m_socket.disconnect();
m_socket.deleteLater();
qDebug()<<temp;
QTcpSocket *m_socket=new QTcpSocket;
connect(m_socket,&QTcpSocket::disconnected,[=]{
qDebug()<<temp<<"Disconnected";
//m_socket->disconnect();
m_socket->deleteLater();
delete m_socket;
});
connect(m_socket,&QTcpSocket::connected,[=]{
emit connect_ok(temp);
qDebug()<<temp;
});
m_socket->connectToHost(ipstr, ipint, QTcpSocket::ReadWrite);
m_socket->waitForConnected(timeout);
m_socket->disconnectFromHost();
emit try_one(-1);
@@ -211,7 +217,7 @@ void dispatch::run()
//qDebug() <<str_ips_list.at(ii)<<":"<< ports_list.at(iii);
qDebug()<<"now:"<<this->now_thread_num<<" - set:"<<this->set_thread_num;
//qDebug()<<"now:"<<this->now_thread_num<<" - set:"<<this->set_thread_num;
connecttry=new trytry;
@@ -222,13 +228,13 @@ void dispatch::run()
connect(connecttry,&trytry::try_one,this,&dispatch::f_one);
connect(connecttry,&trytry::connect_ok,[=](QString temp){emit connect_ok(temp);});
/*
connect(connecttry,&trytry::finished,[=]{
connecttry->disconnect();
connecttry->quit();
connecttry->wait();
});
*/
connecttry->start();
jindu=(quint16)(((qfloat16)(now_scan)/(qfloat16)(scantimes))*100);
+7 -1
View File
@@ -58,7 +58,7 @@ Widget::Widget(QWidget *parent)
ui->threads->setReadOnly(false);
ui->stard_scan->setText("start scan");
dispatch_thread->disconnect();
//dispatch_thread->disconnect();
dispatch_thread->quit();
dispatch_thread->wait();
//delete dispatch_thread;
@@ -320,6 +320,12 @@ Widget::Widget(QWidget *parent)
});
connect(ui->clearoutput, &QPushButton::pressed, [=]()
{
ui->outputlist->clear();
});
}
Widget::~Widget()
+15 -15
View File
@@ -97,25 +97,12 @@
<string>线程</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>10</x>
<y>240</y>
<width>53</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>扫描结果</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>60</x>
<y>240</y>
<width>91</width>
<width>81</width>
<height>24</height>
</rect>
</property>
@@ -776,6 +763,19 @@ domain.com</string>
<string>;</string>
</property>
</widget>
<widget class="QPushButton" name="clearoutput">
<property name="geometry">
<rect>
<x>90</x>
<y>240</y>
<width>71</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>clear output</string>
</property>
</widget>
</widget>
<resources/>
<connections/>