H
H
henecs2014-03-21 13:10:03
Qt
henecs, 2014-03-21 13:10:03

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>память выделяется при старте 
  // освобождается  деструктором 
}

potrScanner.zip

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-03-21
Protko @Fesor

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.)

@
@ntkt, 2014-03-25
_

I think you are confusing the local sockets you control with the remote ports on another host (another machine). On another machine, only the software on that same machine can close them, but you can't on your own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question