Operating System - HP-UX
1823942 Members
3504 Online
109667 Solutions
New Discussion юеВ

define a listening port - tcp

 
SOLVED
Go to solution
ran_li
Regular Advisor

define a listening port - tcp

Hello all,

How can I define a listening port on hp-ux 11i. Thanks.

8 REPLIES 8
Antonio Cardoso_1
Trusted Contributor

Re: define a listening port - tcp

Hi

could you tell more precisely what your concern is?
If a programming matter, the socket creation primitives provide the ability to control socket port numbers.

If other, please explain...

antonio.
ran_li
Regular Advisor

Re: define a listening port - tcp

thanks for the question.

A programmer came to me and ask for a listening port for his socket programming. I m not sure how to create one for him.

Say I want to open a port at 30001 and use

netstat -a

to see it. Is this possible? or I mess up the concept. Please point out.

Regards!
A. Clay Stephenson
Acclaimed Contributor

Re: define a listening port - tcp

In that case, run netstat -a and see if any listeners are bound to that port number. Lsof can also be used to identify ports in use. However, your programmer is not playing by the rules. He should consult
http://www.iana.org/assignments/port-numbers
and see if this is already a port assigned by IANA for a registered use (30001 is). If this is an important application, he should go through the procedure and get his port
reserved.
If it ain't broke, I can fix that.
Mel Burslan
Honored Contributor
Solution

Re: define a listening port - tcp

it is upto the programmer to create a socket and start listening on a port above 1024 (lower range is reserved for OS). I am not a programmer of any sort but as long as the port, that the programmer needs, is not occupied by another process, he/she should be able to listen to the port by a properly written program. Either the programmer does not have any knowledge about socket programming or he/she is not expressing the needs to you properly as the question did not make any sense.

What is the purpose of this request ? does the programmer need your server to listen to a remote commnunication coming from another host on this 30001 port ? Or he wants to write program to listen to this port and wants you to open it. If the situation is the latter, you as the sysadmin have nothing to do. It is all upto him to write his code to listen that port.

More information, especially the purpose of this request will be the most helpful.
________________________________
UNIX because I majored in cryptology...
ran_li
Regular Advisor

Re: define a listening port - tcp

Thanks for the explanation.

>> does the programmer need your server to listen to a remote commnunication coming from another host on this 30001 port ?

I believe above is the purpose. He is planning to transfer something between two hosts. In this case, do I need to do anything about it as a sysadmin? or he as a programmer needs to write a program to listen at that port. Thanks.

Regards!
Mel Burslan
Honored Contributor

Re: define a listening port - tcp

yes you are right. sysadmin does not "have to DO" anything. If he needs this port to listen, he needs to come up with a simple executable to accomplish his purpose. As far as you, the sysadmin goes, you may not know what type of communication this is and what it is expected to do. It is totally upto the programmer to come up with the listener. You just need to verify (by running netstat -an | grep port_num) that the port he intends to use, si not already occupied by some other process.

HTH
________________________________
UNIX because I majored in cryptology...
Antonio Cardoso_1
Trusted Contributor

Re: define a listening port - tcp

additionally, from HP-UX 11.00, anonymous port range is from 49152 to 65535 => that is the range of ports where system assigns ports when creation requests come with zero port number.
This range is controlled by ndd variables xxxx_anon_port (e.g. tcp_largest_anon_port).

Using port number 30001 or any other outside anonymous range is OK.

antonio.
Richard Darling
Trusted Contributor

Re: define a listening port - tcp

1) Setup additional port for :
a) add to /etc/services file:
/protocol(ex. tcp)

b) add to /etc/inetd.conf file:
stream tcp nowait path to program
(man inetd.conf for selections for above)
c) Reconfigure the Internet daemon:
inetd -c