Java port scanner problem
I have written a small port scnaner in Java. But I want to add some more functionality to it. Can anyone help me incorporate the following in my program:
1. List out the service that is listening on a particular port.
2. Close an open port (>1024, of course)
Help with example code would be very welcome.
Re: Java port scanner problem
Depending on your desired functionality, this could range from easy to difficult.
Originally posted here by benipegu
List out the service that is listening on a particular port.
The easy solution, nab a copy of /etc/services off of any nix distribution (attached in case you don't have access to one) and write a way to parse the file (probably want it in your own format at that point) and then pump out the entries when you list the ports.
Apart from an undesirable non-portable hack/wrapper scripts, I am not sure this could be done. I don't know for certain, but it is based on what I've run into in other areas in terms of controlling anything below the VM level. The VM operates in an isolated environment, it's tough to do things that exist outside this environment at all, let alone without wrappers.
Close an open port (>1024, of course)