在accept4中声明{sa_family = AF_UNIX}和[110-> 2]的含义是什么?

问题描述 投票:0回答:1

我在我的机器人中做了一个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,所以我想知道读取/写入套接字的进程是否已经死了现在,如果我能得到他的名字。)谢谢!

c linux-kernel
1个回答
1
投票

来自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]>
  • 8sockfd的价值。来自男人:the listening socket, sockfd
  • 2468文件描述符的inode编号
  • 存储在指针.sa_family指向的内存中的结构struct sockaddr中的struct成员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;
  • 函数返回后2addrlen值。来自男人:will contain the actual size of the peer address
  • qazxsw poi flags qazxsw poi。来自男人:qazxsw poi
  • 0返回文件描述符。来自男人:flags
  • If flags is 0, then accept4() is the same as accept(). inode number of 9th文件描述符
© www.soinside.com 2019 - 2024. All rights reserved.