# sockstat and unix sockets



## antolap (Apr 16, 2020)

Hi
How to see which processes are connected to which listening processes?

for example:
process A (connected processes: x, y, z..)
process B (no connected process)

Is it possible?


----------



## SKull (Apr 16, 2020)

Doesn't sockstat do that by default?
Anyway...


```
man sockstat
```
says:

```
-u          Show AF_LOCAL (UNIX) sockets.

If neither -c or -l is specified, sockstat will list both listening and connected sockets.
```

Hope that helps


----------



## antolap (Apr 16, 2020)

I'd like to see the associations among clients and server


----------



## putney (Apr 16, 2020)

antolap said:


> I'd like to see the associations among clients and server



I'm not really sure what you mean, but sockstat will tell you the name of the unix process that's listening - server? - and the IP address of a remote machine that's connected  - client? - e.g. for IPv4 on port 443

```
% sockstat -p 443 -s -4
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS       PATH STATE   CONN STATE 
www      nginx      97042 3  tcp4   192.168.1.87:443      192.168.1.64:60910                 ESTABLISHED
www      nginx      97042 8  tcp4   *:443                 *:*                                LISTEN
```


----------



## Martin Paredes (Apr 18, 2020)

Maybe with fstat(1) from base system or lsof(8) from sysutils/lsof can tell you the process that has opened the socket file, check the -U parameter in lsof


----------

