- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Question about Unix Socket !
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
07-06-2004 08:17 PM
07-06-2004 08:17 PM
I am just wondering whether a client program can occupy a port no. e.g. 10000 that already defined in the /etc/services file for another services ?
What is the difference for -
1. the defined services is up and running therefore listening to the port 10000
2. the defined services is down / not running.
Thanks for your advice.
Best Regards,
Chris,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 08:23 PM
07-06-2004 08:23 PM
Re: Question about Unix Socket !
Easiest way to see if anything is running on a TCP port is: -
telnet localhost 10000
If you get
telnet: Unable to connect to remote host: Connection refused
then there is no service running.
The /etc/services file will simply let you achieve the same with: -
telnet localhost console (since in /etc/services, port 10000 is defined as service called console, so it just looks up port 10000).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 08:56 PM
07-06-2004 08:56 PM
Re: Question about Unix Socket !
# netstat -a
This command will show you if any service is listening at any particular port, whether the connection is established and so on.
Just have a look at the output.
See man netstat.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 09:01 PM
07-06-2004 09:01 PM
Re: Question about Unix Socket !
Just to add something :
If the defined service is up and running you will get connection listening at that port.
If the client has established a connection via that port then you will get the status as established at that port.
You can view this by
#netstat -na |grep 10000
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 09:02 PM
07-06-2004 09:02 PM
Re: Question about Unix Socket !
Thanks for the input. I would like to know is there a way to restrict the usage of the network port in some way ??
E.g. reserve 10000 to particular program so that other programs cannot acquire this port no matter the particular program is running / stopped.
Or the restriction can be lying on the user level, so that particular user will only be able to user a range of ports.
Any tools (open source / commercial / built-in) available to achieve this task.
Thanks in advance.
Cheers,
Chris,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 09:12 PM
07-06-2004 09:12 PM
SolutionThere doesn't appear to be an way of reserving network ports, unless you
make your application a 'client' of inetd, like ftpd/telnetd/etc.:
Adding to /etc/services does not reserve the ports, although I would suggest
if you use particular ports consistently add them in there as a 'flag' to
let other users know you are using those ports. Better than nothing!
"The /etc/services file is documentation. It does not reserve a port. Some
programs will refer to the port by service name so if it is not listed, the program
will abort."
The way to go with this issue is to watch what ports you use:
"look at a netstat output to see what ports are being used while the machine
is busy, and pick a set of ports that are far away from the others. Also,
have a look at this:
http://www.iana.org/assignments/port-numbers
This explains the well-known, registered, and dynamic/private ports concept.
If you stay between 49152 and 65535, chances are, you're safe. Most of the
registered ports are not likely to be used on your system, so if you want a
lower number for an internal app, you shouldn't have a problem if you just
avoid the ones on your particular systems."
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 09:12 PM
07-06-2004 09:12 PM
Re: Question about Unix Socket !
You can define the service in /etc/service as follows:
and then define the same in /etc/inetd.conf.
Restart you inetd daemon.
# /usr/sbin/inetd -c
Hope that helps.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 09:30 PM
07-06-2004 09:30 PM
Re: Question about Unix Socket !
By defaul 1,1023 ports called as privillaged ports. Ports and the service using them are defined in /etc/services files. If we want to use the port < 1023,we have to use bindservport() call.
To check the weather the service is running or not,we can use netstat -na | grep "port-number". Some service will create process ID to indicate that it is running. We can get with ps.
If you want to startup the service by default and down while normal down,we have to use the /etc/inetd.conf with inetd(eamon). All the service starup success and failure are stored in syslog.log file.
If one service is using one port,other service can not use that port. Service up and down can be done on the service which are included in the inetd(eomon). If a Service running means, it is executed as a standalone one on shell and not running means,it is process stopped.
We can give the restriction to the ports for the specific service by adding that in inetd.conf file and /etc/service files. No other service cannot use that port. see the /etc/services file,and add an entry for your new service. Make an entry in inetd.conf and start the inetd with -c option to reconfigure.
Make a script, to check which service is using your needed port and service setup in /etc/inetd.conf file. comment the entries and allocate them for.
Regards,
Muthukumar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 11:12 PM
07-06-2004 11:12 PM
Re: Question about Unix Socket !
The best way is to get your application to sit on the port doing nothing except servicing requests. If it doesn't exit, nothing else can use the port.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2004 07:01 PM
07-07-2004 07:01 PM
Re: Question about Unix Socket !
Thanks for your inputs and advice. I think the problem now will be on our operation side that they need to stop the service before running a batch and restart it after the batch. The downtime will be more than 10 hrs.
Therefore, within this period, the registered port will be free from using by other process. Problem happened like winning the lottry that we have another process occupied the port and hanged for no reason one day.........and that raised everybody's attention in finding the root cause as well as the permanent solution.
Thanks you very much again.
Cheers,
Chris,