Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Valid Port Range

 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
with 64k to work with the valid port range is (1024 x 64) so thats 0 through 65535, problem is the server can listen on port 0 for example, but the client cannot connect, or similar possible problems, my feeling on this is that we should allow all between that range, even well known reserved ports, but it should be the users reposibility to ensure that on their operating system the port configured can be used, is this correct?
 
Damian Ryan
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I did. Just make sure you document your assumptions.
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Damian Ryan:
This is what I did. Just make sure you document your assumptions.

agreed, done it is then, thank you
 
SrinivasMA Srini
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If the port number is out of range catch the exception also. It is advisable to catch the following exception:
catch( IllegalArgumentException illegalArgumentException )
{
System.out.println( " Port number is out of range. It is recommended to use valid port number.");
System.exit( 0 );
}
Cheers
Srinivas
SCJP,SCJD
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!