Is there a way to get a list of all open sockets ( socket address or socket descriptor ) in Linux using C in user-space or kernel?
Thank you
Open and read the following:
/proc/net/tcp
- a list of open TCP sockets
/proc/net/udp
- a list of open UDP sockets
/proc/net/raw
- a list all the "raw" sockets
These are like "regular" files that you open and read with a filehandle and will give you all the information you could possibly need about each socket.
This program may be useful for you and demonstrates how to parse the /net/proc/* files sockstat.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With