0

Hi,

I was wondering if there was a way to find open ports on a server. I'm trying to write a program that tells the user whether they have any open ports or not and if they do, which ones and how to fix them.

Thanks.

3
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by jwenting
0

there are thousands of ports, i think it ranges from 1-65,536 the first 1,024 are reserverd ports even though not all of them have been claimed yet, so program should generally try and refrain from usign them, i think you would have to go through every single port and check to see if it is occupied to do this

also check out:
http://www.iana.org/assignments/port-numbers

0

thanx, thats what i thought. do you know how to check if they're occupied or not?

Thank you

0

do you think you might be able to give me some code (just 2 point me in the right direction, not give me the "answer") or the method to find the open ports?

Thank you.

0

Try to open a ServerSocket on the port. If you can, the port was available and you immediately close the socket again.
If you cannot, you get an exception (or an errorcode, check the API docs for ServerSocket) and you know the port is in use already.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.