Are there any conventions out there for selecting what port(s) your app
should use for application-specific communication?
Our app runs on multiple servers that must communicate. We're using
http, but can't use port 80 because there is another webserver using it
on each server. (And we don't want to use more IPs than we have to, or
do something ugly like virtual hosts across processes.)
So we have to pick another port number. We could use 8080 like Tomcat,
but there might also be a Tomcat instance running that we don't control.
So, in general, is there any rule you should use when selecting a port
number, other than picking one > 1024?
>
> So, in general, is there any rule you should use when selecting a port
> number, other than picking one > 1024?
>
Look at /etc/services or http://www.iana.org/assignments/port-numbers
and pick one that isn't being used. Usage above 20,000 is fairly sparse.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
> On Wed, 20 Oct 2010 15:02:41 -0500, Spud wrote:
>
> >
> > So, in general, is there any rule you should use when selecting a port
> > number, other than picking one > 1024?
> >
> Look at /etc/services or http://www.iana.org/assignments/port-numbers
> and pick one that isn't being used. Usage above 20,000 is fairly sparse.
That's what we've done with our application. I'd also suggest making it
possible to reconfigure it to another user-configurable port just in
case they happen to be using the one you default to.
--
Steve W. Jackson
Montgomery, Alabama
Don't use a "well-known" port which is already assigned by IANA to
another application/protocol. Just because you don't currently use that
application/protocol doesn't mean you won't want to next week. Make it
configurable so you can move it to a different port if you have to.
On UNIX/Linux systems a fairly comprehensive list is available in
/etc/services, also available at the following URL:
http://www.iana.org/assignments/port-numbers.
--
Nigel Wade
>That's what we've done with our application. I'd also suggest making it
>possible to reconfigure it to another user-configurable port just in
>case they happen to be using the one you default to.
You can make it a system property. If the client needs to modify it,
they can just use a -D command line switch.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Microsoft has a new version out, Windows XP, which according to everybody is the "most reliable Windows ever." To me, this is like saying that asparagus is "the most articulate vegetable ever."
~ Dave Barry
>
>So, in general, is there any rule you should use when selecting a port
>number, other than picking one > 1024?
Some programs let the user choose the port number during the install
process. It can then burn it in to the program in any of a number of
ways.
> Are there any conventions out there for selecting what port(s) your app
> should use for application-specific communication?
Yes. Let the operating system pick an unused one for you.
> So we have to pick another port number. We could use 8080 like Tomcat,
> but there might also be a Tomcat instance running that we don't control.
If you are going to pick one manually, you MUST have control of the OS
and all ports to assign one. Otherwise, you just really can't. Talk
the administrator and see if he or she will reserve one for you.
> So, in general, is there any rule you should use when selecting a port
> number, other than picking one > 1024?
Don't select ports close to 1024, they're typically used by NAT and
other temporary ports. Talk to the sys-ops, hopefully they'll have a
block of ports that are manually assigned and can give you one out of
that block.
Roedy Green wrote:
> Some programs let the user choose the port number during the install
> process. It can then burn it in to the program in any of a number of
> ways.
Excellent point. One such way is
<http://download.oracle.com/javase/6/docs/api/java/util/prefs/package-summary.html>
--
Lew
Not very wise for a server/service. How do the clients get to know what
port the operating system allocated to the server when it started?
OTOH, that's exactly why portmapper and other similar services were
developed. To allow a server to listen on whatever port was available,
register that port and the service with portmapper, and then clients can
query the portmapper to locate them. Then along came firewalls...
--
Nigel Wade
Or a simple properties file.
I have never liked the prefs API.
Arne
"Nigel Wade" <nmw-...@ion.le.ac.uk> wrote in message
news:8id1s5...@mid.individual.net...
It's kind of amusing how the most sophisticated networking apps sit upon
something as ancient as IP. Imagine if you were building a registry for
networked services: would you have each one identify itself to the world
solely by a 16-bit integer?
It's also kind of amusing how the most sophisticated intellect sits upon
something as ancient as meat.
http://baetzler.de/humor/meat_beings.html
> Imagine if you were building a registry for
> networked services: would you have each one identify itself to the world
> solely by a 16-bit integer?
Its probably more a question of management. If IANA rented out 16-bit
port number registrations by the year and if you lost registration for
any protocol that constituted less than (say) 0.01% of Internet traffic
in a year, the range of "well known port numbers" would probably be
adequate for quite some time.
Anyway, a ridiculous (and increasing?) number of services now sit on a
single port, HTTP, mainly as a way of bypassing uncooperative firewall
administrators? For example, you can have a stupidly large number of
distinct SOAP services sitting on port 80.
On a related note, a 16-bit port number plus a 128-bit IP address† seems
to me to be a address space with sufficient room to swing the occasional
cat. A port-mapper approach makes the limit of less than 65,536 distinct
types of service per single computer somewhat irrelevant.
Just my 2-bits worth.
--
RGB
†V6
> On 23/10/2010 03:13, Mike Schilling wrote:
>> It's kind of amusing how the most sophisticated networking apps sit upon
>> something as ancient as IP.
>
> It's also kind of amusing how the most sophisticated intellect sits upon
> something as ancient as meat.
>
> http://baetzler.de/humor/meat_beings.html
There's a rather good short film version of that:
http://www.youtube.com/watch?v=gaFZTAOb7IE
On the subject of portmappers, don't forget good old TCPMUX:
http://en.wikipedia.org/wiki/TCP_Port_Service_Multiplexer
tom
--
I really don't know what any of this shit means, but it looks
impressive. -- zerolives, on YVFC