The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Choosing a port for local server software

I'm setting up a program that runs as a simple web server and font-end in a browser (same way Google Desktop works), and I've always given it a random high number port, such as 62543 or something along those lines.

Am I doing this right?  Or are there a range of ports that are available for non-standard purposes?
Ben Mc Send private email
Wednesday, December 07, 2005
 
 
RFC 793 section 2.7 reserves ports zero through 256 for spectific uses, but allows operating systems to reserve additional ports for shared resources (and things like web server redirects).  In practice, I've found that anything above 9000 is fair game.
Anonymous Coward
Wednesday, December 07, 2005
 
 
Ports that are really high are typically used for ephemeral ports. Yours is probably set way to high. Typically you would use something greater than 5000 but less than 16000. You should google for known ports and ranges to pick something a little bit lower. But in the end it really won't matter. Especially since you should allow the end user to pick the actual port number used through configuration.
Turtle Rustler
Wednesday, December 07, 2005
 
 
I did Google for this, and found some lists.  The lists I did find were extremely thorough.  They had various applications and services listed for ports way into the thousands.  Thanks for the RFC info, that should help a lot.  I do want to use a lower port number, but I haven't yet because I don't want to conflict.
Ben Mc Send private email
Wednesday, December 07, 2005
 
 
http://www.iana.org/assignments/port-numbers
is a good start.  Then, just to be safe, google for the specific port you wish to use.  In the end, I (the installer) should have the option to change the port, just in case I have locally used the port in question.
MSHack
Wednesday, December 07, 2005
 
 
Is there a programable interface to discover/get/create port assignments?

This area looks similar to DNS when based on updating hosts file before DNS servers.
John Griffiths Send private email
Thursday, December 08, 2005
 
 
"Is there a programable interface to discover/get/create port assignments?"

Because there's an infinite number of possible port numbers (well, not infinite but a very large number), most operating systems do not have a mechanism for discovering port numbers.

You can attempt to request (or bind) a port and the operating system will tell you if you can take it, or if someone's already using it.  It usually will not tell you who's using it.

You can attempt to access (or connect to) a port and the operating system will either allow the connection, reject the connection or state/pretend the port is not in use.

Google for your operating system plus the keywords "bind port API" or "connect port API".

Also, the practice of attempting to connect to every port on another machine in order to determine which ports exist, is called "port scanning".  Google that as well.  Just beware that most people consider port scanning to be the prelude to an attack and may sic their cyber security on you if you probe their systems.
Anonymous Coward
Thursday, December 08, 2005
 
 
Err...  I misread the question.  I think.

For security reasons, nobody broadcasts a list of available services (and their corresponding port numbers), with the possible exception of early versions of Microsoft Windows.  :)

So no, you cannot query a remote site for services the same way you can query DNS entries.  Some sites may offer RPC services, COBRA, SOAP or the like, but those requests/responses are not conducted over a standard port.  You must already know where they are before you can access them.
Anonymous Coward
Thursday, December 08, 2005
 
 
"Because there's an infinite number of possible port numbers"

It's only a 16-bit integer.  So hardly infinite and not very large number either.
Almost H. Anonymous Send private email
Thursday, December 08, 2005
 
 
:)  I'm sure that's a limitation of the operating system in question.  You may have to redesign some algorithms for efficiency, but there's no good reason why it can't be a 32 bit integer.

Still a small number, but 10 years from now when every device talks to every other device through a wireless interface, 64 bit ranges will be common.
Anonymous Coward
Thursday, December 08, 2005
 
 
> I'm sure that's a limitation of the operating system in question.  You may have to redesign some algorithms for efficiency, but there's no good reason why it can't be a 32 bit integer.

Unfortunately, you'd have to modify the TCP/IP spec to have a 32 bit integer as a port number. ;-)
ice
Friday, December 09, 2005
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz