Linux API to determine sockets owned by a process

后端 未结 7 1844
梦毁少年i
梦毁少年i 2020-12-23 02:01

Is there a Linux library that will enable me to tell what IP sockets are owned by what processes? I guess I\'m looking for the programmatic equivalent of lsof -i

7条回答
  •  臣服心动
    2020-12-23 02:19

    You can read them from proc filesystem. The 'files' you probably want to look at are found in /proc//net (namely tcp, udp, unix)

    Here's some examples on using the proc filesystem

提交回复
热议问题