Linux API to determine sockets owned by a process

后端 未结 7 2095
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 01:50

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:15

    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

提交回复
热议问题