In linux, netstat command tells us information of active sockets in system.
I understand that netstat uses /proc/net/tcp to acquire the system
netstat
/proc/net/tcp
Check out the source for ss:
https://github.com/shemminger/iproute2/blob/master/misc/ss.c
Basically it directly queries the kernel and can respond much faster than netstat.