JDK-4240619 : A way to refer to port number through an equivalent service name.
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.1.8,1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-05-24
  • Updated: 1999-12-14
  • Resolved: 1999-12-14
Related Reports
Duplicate :  
Description

Name: vi73552			Date: 05/24/99


It would be useful to have a way to define an internet address
specifying the name of a service instead that the port number.
The service name should be mapped to the port number via DNS 
services ( the same way the logical host name is translated in a phisical internet
address ).

For instance, there could be a ne  constructor for the socket class 
with this interface :
   Socket ( String hostname, String service_name )

I guess the problem is to find a platform-independent method
equivalent to the C function getservbyname(), supplied by the
Berkley socket library.
(Review ID: 83403) 
======================================================================

Name: krT82822			Date: 12/03/99


any 1.1.8 or higher JDK

I need a way to obtain the port number to use for my application by querying
for the service name (getservbyname() in C). The services table seems to be a
pretty standard part of TCP/IP, so it would appear to be a reasonable request
to include access to it from java.net. To me, it is no different than being
able to query an IP address using the host name.

The reason for this is that I have potentially many processes talking to each
other on the same machine. In order to have a guaranteed single place where the
port is configured, the services table must be used so I can rely on the IP
stack instead of reading some configuration file that could be duplicated for
each process.
(Review ID: 98602)
======================================================================

Comments
WORK AROUND Name: vi73552 Date: 05/24/99 I use my own configuration parameters to avoid to hard-code port number in the client program ( while for host name I rely on DNS configuration to have flexibility in the address of my server ). ====================================================================== Name: krT82822 Date: 12/03/99 none that would be as secure as relying on the IP stack for this functionality (Review ID: 98602) ======================================================================
11-06-2004