c - accept4 中的声明 {sa_family=AF_UNIX} 和 [110->2] 是什么意思?
问题描述
我在我的 android 中做了一个 strace,我得到了以下行
accept4(8<UNIX:[246]>, {sa_family=AF_UNIX}, [110->2], 0) = 9<UNIX:[2512219]>
我不明白 {sa_family=AF_UNIX} 做了什么(它应该是一个 sockaddr 指针,但它在路径和内存地址方面指向哪里?)我想知道 110 和 2 的含义以及为什么 110 是指向 2 以及此操作返回的确切内容。
(我真的很好奇这样创建的套接字的对等点,因为我在任何 proc/PID/fd 文件中都找不到 inode 2512219 所以我想知道读/写套接字的进程是否已经死了现在,如果我能知道他的名字。)谢谢!
解决方案
来自man accept4:
int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
accept4(8<UNIX:[246]>, {sa_family=AF_UNIX}, [110->2], 0) = 9<UNIX:[2512219]>
8
是sockfd
价值。来自男人:the listening socket, sockfd
246
是8
文件描述符的 inode 编号- 指针指向的内存中存储的结构体
.sa_family
中的结构体成员的值为struct sockaddr
addr
AF_UNIX
- 来自男人:
[addr] It is filled in with the address of the peer socket, as known to the communications layer
。 110
输入值addrlen
(指针指向socklen_t
的内存中存储的整数addrlen
)。来自男人:the caller must initialize it [addrlen] to contain the size (in bytes) of the structure pointed to by addr;
2
addrlen
函数返回后的值。来自男人:will contain the actual size of the peer address
。0
标志flags
。来自男人:If flags is 0, then accept4() is the same as accept().
9
返回的文件描述符。来自男人:a nonnegative integer that is a file descriptor for the accepted socket
2512219
9
第文件描述符的 inode 号
推荐阅读
- http - 在 DNN 8.00.04 上安装 2sxc v9.33 后出现 HTTP 错误 404.0
- c - c中的合并排序算法
- java - 带有 Spring-Boot 的 Hazelcast - 无法序列化“org.springframework.session.MapSession”
- apache - 仅当子域中的特定字符串匹配时才使用 Apache ProxyPass
- scala - Spark SQL 使用窗口 - 根据列条件从当前行之后的行中收集数据
- javascript - SAPUI5:异步/等待的“意外令牌功能”
- php - PHP/ODBC 连接在没有凭据的情况下无法工作
- neo4j - neo4j:使用后的多个值
- ruby-on-rails - 如何使用 RSpec 控制器规范触发并发请求?
- scala - 如何安全地对 spark 数据框行进行 getAs 操作?