令s
为由socket(PF_INET, ...)
创建的套接字的文件描述符。
如果我调用 accept(s, (struct sockaddr *) &addr, ...)
,其中 addr
的类型为 struct sockaddr_in
,我可以假设返回的地址格式是IPv4,即
addr.sin_family == AF_INET
?
最佳答案
来自The Open Group's描述:
The
accept()
function shall extract the first connection on the queue of pending connections, create a new socket with the same socket type protocol and address family as the specified socket, and allocate a new file descriptor for that socket.
关于unix - 如果我将accept(3)应用于IPv4套接字,我可以假设它返回IPv4地址吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10960918/