How to use lsof(List Opened Files) in a C/C++ application?

后端 未结 4 510
死守一世寂寞
死守一世寂寞 2021-01-05 08:20

Is there any way to get all opened sockets using c++? I know the lsof command and this is what I\'m looking for, but how to use it in a c++ application?

4条回答
  •  无人及你
    2021-01-05 08:46

    Just open the files in /proc/net, like /proc/net/tcp, /proc/net/udp, etc. No need to slog through the lsof sources. :)

提交回复
热议问题