List TCP sockets when netstat is not available

Today I found myself on a Linux machine and needed to check which processes are listening for network packets.
Usually I use netstat for such tasks, but on this machine it was not available.
Luckily there was ss available, and the following command gave me the processes listening for TCP packets:

ss -n -A tcp -a -p state listening