- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- Re: Choosing a port number for my server.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2006 12:22 AM
03-13-2006 12:22 AM
by root user. This will be used by many
customers. I need to define a port number for
this server. I understand that a good way of
doing this is to hardcode a service name
against a 'Registered' port # (in the range
1024-49151), in the /etc/services file and
then make the client use getservbyname() to
lookup the actual port number. Is this the
correct/best way to do this ?
Are there any other issues to be considered
while selecting a port # ?
- Senthil.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2006 01:10 AM
03-13-2006 01:10 AM
Re: Choosing a port number for my server.
Then make your program as flexible as possible. Hardcoding something like a port number is risky. You'd be better off having a configuration file and/or a switch that would allow a change to the port number after the program has been compiled.
Can't tell you how many customers we have talked with having to deal with an old program that is inflexible and is now in conflict with another program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2006 01:28 AM
03-13-2006 01:28 AM
Re: Choosing a port number for my server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2006 05:31 AM
03-13-2006 05:31 AM
Re: Choosing a port number for my server.
> risky [...]
Perhaps that's why the OP said "hardcode a
service name", rather than "hardcode a port
number".
And, yes, that's the usual way to do this
sort of thing.
The primary consideration when selecting a
port number is avoiding a collision with
other services which use user-selected port
numbers. Having a service name in
"/etc/services" (or the corresponding NIS
data base) is a good way to do this.
Some effort to coordinate port assignments
may still be needed if you need to deal with
external systems whose "services" file (or
NIS data base) may already include locally
defined services.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 04:26 PM
03-20-2006 04:26 PM
Re: Choosing a port number for my server.
replies !!
>> You can also improve security by not
>> running the program as root.
>> If you will open an unprivileged port,
>> the program does not needs to run as
>> root.
True. But I need to run as root for
some other reasons.
>> Some effort to coordinate port
>> assignments may still be needed if you
>> need to deal with external systems
>> whose "services" file (or
>> NIS data base) may already include
>> locally defined services.
So, What is this NIS data base ? Is it
the same /etc/services file on the NIS
server or is it some other file ? (In other
words, does getservbyname() on a NIS
client, look for /etc/services file on the
NIS server too ?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 05:06 PM
03-20-2006 05:06 PM
SolutionIt could be anything, depending on how NIS
is configured. The default is probably
"/etc/services" on the NIS master, however.
I'm not up-to-date on NIS, but these data
were once kept in "/var/yp/Makefile" on the
NIS master server.
What getservbyname() does is governed by the
system configuration. On Solaris,
"/etc/nsswitch.conf" tells it where to get
its information. On Tru64, it's
"/etc/nsswitch.conf" or "/etc/svc.conf".
(When it's using NIS, getservbyname() calls
NIS functions which communicate with an NIS
server. It will not access the NIS data base
file directly.)
In general, you just use getservbyname(), and
let the system manager worry about where the
actual data are kept.
See "man getservbyname" for the local fine
print.