Operating System - HP-UX
1836972 Members
2561 Online
110111 Solutions
New Discussion

Re: Two processes allocated to one port???

 
support_5
Super Advisor

Two processes allocated to one port???

Hi all,

When I use the lsof (for HP-UX 11.00) command (dowloaded from HP-UX porting and archiving center), I get the following:
[palau]:/root # lsof -i -P | grep 1522
ora_pmon_ 14858 oracle 14u inet 0x41757668 0t845784 TCP p01.workcover.qld.gov.au:56302->p01.workcover.qld.gov.au:1522 (EST)
tnslsnr 20759 oracle 7u inet 0x572c4668 0t0 TCP p01.workcover.qld.gov.au:1522 (LISTEN)
tnslsnr 20759 oracle 11u inet 0x66c07c68 0t845784 TCP p01.workcover.qld.gov.au:1522->p01.workcover.qld.gov.au:56302 (EST)
tnslsnr 26248 oracle 7u inet 0x67c03e68 0t0 TCP p08.workcover.qld.gov.au:1522 (LISTEN)
[palau]:/root #

That might be hard to see, but basically, it says that process id 20759 and 26248 are both listening on port 1522. How can this be?

I don't understand how two processes can be sharing the same port number? If I do a ps -ef of these two processes, this is what I find:

[palau]:/root # ps -ef | grep -e 20759 -e 26248 | grep -v grep
oracle 20759 1 0 Apr 13 ? 0:44 /p01/oracle/rdbms/v8.1.7/bin/tnslsnr PRCARDB -inherit
oracle 26248 1 0 Apr 13 ? 0:00 /p08/oracle/rdbms/v8.1.7/bin/tnslsnr LISTENER -inherit
[palau]:/root #

As you can see, they are related somewhat. But can anyone explain how two processes can share the same port? I am sure that this isn't possible.

Cheers,

- Andy Gray
4 REPLIES 4
Christopher Caldwell
Honored Contributor

Re: Two processes allocated to one port???

Though the two process seem to be listening on the same port, the end points are actually varied by IP (i.e. A.B.C.D.1522 and A.B.C.E.1522). From the application's perspective, these are two different places.

You can achieve this effect by passing an actual IP address when the socket is bound as opposed to INADDR_ANY (bind to a certain port on every available address).


Ceesjan van Hattum
Esteemed Contributor

Re: Two processes allocated to one port???

Sorry if I'm wrong, but i always thought that services (not processes) are connected to ports (see /etc/services).
Processes and system-calls are connected to a socket by bind, making streams possible.

Regards,
Ceesjan
support_5
Super Advisor

Re: Two processes allocated to one port???

Hi,

Thanks for the replies.

I think you will find that inetd listens on ports as specified in /etc/services, so it is actually just a process which listens to those ports and if a connection arrives for one, spawns a child process as per /etc/inetd.conf, passing the connection to the new child process eg telnetd.

And yes, p01 and p08 are DNS names for service_guard packages, which are actually just different IP's but connected to the same server (on the same network card even), but just different IP's on the same network card. Therefore, the endpoints, although they have different IP addresses, is actually the same machine. Now here is where my lack of knowledge regarding this may arise: Are there 64k ports allocated per machine, or are there 64k ports allocated per IP address per machine? Ie is there only on pool of 64000 ports that a server knows about, or are there multiple pools of 64000 ports on a server which exist on each IP address? I always assumed that there was one pool of 64k ports per server, but what you say seems to suggest that there is one pool of 64k (ie 64000) ports per IP address. Which is it?

So anyway, I'm assuming then, that it isn't a problem that they listen on the same port number, because they are different IP addresses?

Thanks for the help, guys.

- Andy Gray
Steven Gillard_2
Honored Contributor

Re: Two processes allocated to one port???

Theoretically there are 64k ports per IP address. But, a lot of applications (such as inetd) choose to listen on INADDR_ANY as Christopher points out, which means they tie up the port across all IP addresses on the system.

In a serviceguard environment applications must be programmed to listen on only the one package address, so that multiple identical packages can run on the same machine. What you're seeing is completely normal.

The best source of information on this is W. Richard Steven's TCP/IP Illustrated series of books - IMHO Volume I is mandatory on every system administrators bookshelf.

Regards,
Steve