Java PortScanner, check if port is filtered

167 Views Asked by At

I wrote a port scanner in java that works perfectly fine, however I am not sure how to test if a port is closed and filtered. I have these catch statements that work correctly but I am unsure if my context for them is correct, does TimeoutException mean the socket is filtered? I came about this conclusion from previous examples but couldn't find any source explaining it, if not which exceptions would show the socket being closed or filtered?

        catch(SocketTimeoutException ex) 
        {
            System.out.println("Port " + port + " is filtered");
        }
        catch(SocketException ex) 
        {
            System.out.println("Port " + port + " is closed");
        }
0

There are 0 best solutions below