如何将每个/proc/net/tcp 条目与每个打开的套接字匹配? [英] How can i match each /proc/net/tcp entry to each opened socket?

查看:35
本文介绍了如何将每个/proc/net/tcp 条目与每个打开的套接字匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 /proc/net/tcp 解析套接字信息,虽然我可以识别一些字段,例如内存地址或发送队列使用,但我无法找到每个条目绑定到它的套接字描述符.例如,使用此数据:

I'm trying to parse socket info from /proc/net/tcp and while I can identify some fields, such as memory addresses or send queue use, I can't find how each entry is bound to its socket descriptor. e.g., with this data:

1: 5922140A:E459 D5C43B45:0050 01 00000000:00000000 00:00000000 00000000  1000        0 507218 1 f6ab1300 57 3 12 4 -1  

我想知道对应的socket描述符是哪个.

I want to know which is the correspondant socket descriptor.

推荐答案

取 inode 编号(在本例中为 507218).该套接字的每个打开的文件描述符(同一个套接字可能有多个文件描述符)将显示为以下形式的链接:

Take the inode number (in this case, 507218). Each open file descriptor to that socket (there may be multiple file descriptors for the same socket) will appear as a link of the form:

/proc/<PID>/fd/<N> -> socket[507218]

(其中 是进程 ID, 是文件描述符).

(where <PID> is the process ID and <N> is the file descriptor).

这篇关于如何将每个/proc/net/tcp 条目与每个打开的套接字匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆