Sockets and Ports#
What is listening, what is connected, and which process owns each
socket. ss is the modern tool (replaces netstat); lsof -i
answers the inverse; given a port, which process opened it.
sequenceDiagram
participant SP as Server process
participant K as Kernel socket table
participant CP as Client process
SP->>K: socket, bind(ip port), listen
Note over K: LISTEN entry (ip, port, fd, pid)
CP->>K: socket, connect(ip port)
K->>K: 3-way handshake (SYN, SYN-ACK, ACK)
Note over K: ESTABLISHED entry added
SP->>K: accept
K-->>SP: returns connection fd
CP->>SP: write / send bytes
SP->>CP: read / recv bytes
Note over SP,CP: ss -tulpn or lsof -i read this table for you
operator@system:~$ ss -tulpn
operator@system:~$ ss -ant
operator@system:~$ ss -s
operator@system:~$ lsof -i :8080