[comp.unix.questions] identifying processes that own sockets

allyn@sleepy.UUCP (Mark Allyn) (04/22/91)

The netstat command shows the prototype, local address, and foreign
address for each active internet connection. 

I would like to be able to identify the process that own the socket for
a particular internet connection. 

Using the netstat -A gives the address of the protocol family for
a socket. Is there any way (using iostat, pstat, or anything else) that
I can correlate a particular socket to a particular process id??

Thanks!

subbarao@phoenix.Princeton.EDU (Kartik Subbarao) (04/24/91)

In article <167@sleepy.UUCP> allyn@sleepy.UUCP (Mark Allyn) writes:
>The netstat command shows the prototype, local address, and foreign
>address for each active internet connection. 
>
>I would like to be able to identify the process that own the socket for
>a particular internet connection. 
>
>Using the netstat -A gives the address of the protocol family for
>a socket. Is there any way (using iostat, pstat, or anything else) that
>I can correlate a particular socket to a particular process id??

The ofiles command can help you here. 


You can correlate a protocol's port to a given pid by saying:

ofiles <protcols>.<protnum>

example:
% ofiles tcp.513 

lists all the in.rlogind's on the system, 

and 

% ofiles udp.512 

lists all the comsat processes.

You can see ALL processes on tcp ports by saying:

% ofiles tcp.


Hope this helps.

		-Kartik


--
internet# rm `df | tail +2 | awk '{ printf "%s/quotas\n",$6}'`

subbarao@phoenix.Princeton.EDU -| Internet
kartik@silvertone.Princeton.EDU (NeXT mail)  
SUBBARAO@PUCC.BITNET			          - Bitnet