Answer the question
In order to leave comments, you need to log in
How to close TCP ports (port scanner) / Qt ?
Good day.
I have a small port scanner, it scans a range of ports and displays the result (port status (open or closed)) in a table.
I just can’t find how to close the TCP port for the specified number, maybe someone knows how to close the port, or maybe there are some ideas?
bool scan_port(QString ip,qint16 port)
{
soket->disconnectFromHost();
soket->connectToHost(ip,port);
if (soket->waitForConnected(10))
return true;
else return false;
// soket глобальная переменная
//<code></code>память выделяется при старте
// освобождается деструктором
}
Answer the question
In order to leave comments, you need to log in
shutdown + close?
In order to close some port that is not used by your application, you need to determine the PID of the process using this port, kill it and that's it ... Then it all depends on the connection settings used by that process (SO_REUSEADDR was set or not) and the operating systems. In the worst case, even after killing the process, the port will still hang in time-await mode for some time (due to the fact that at the time of killing, we may not have empty send / receive data buffers, etc.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question