944,093 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 17536
  • Java RSS
May 6th, 2005
0

Finding Open Ports

Expand Post »
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.
Similar Threads
Reputation Points: 12
Solved Threads: 2
Posting Whiz
Ghost is offline Offline
352 posts
since Aug 2004
May 6th, 2005
0

Re: Finding Open Ports

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
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
May 6th, 2005
0

Re: Finding Open Ports

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

Thank you
Reputation Points: 12
Solved Threads: 2
Posting Whiz
Ghost is offline Offline
352 posts
since Aug 2004
May 6th, 2005
0

Re: Finding Open Ports

uhm, maybe a BindException or a PortUnreachableException but i'm not sure
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
May 6th, 2005
0

Re: Finding Open Ports

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.
Reputation Points: 12
Solved Threads: 2
Posting Whiz
Ghost is offline Offline
352 posts
since Aug 2004
May 7th, 2005
0

Re: Finding Open Ports

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.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: tutorials
Next Thread in Java Forum Timeline: Simple Command Line interface -





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC