gpt4 book ai didi

unix - 如果我将它应用于 IPv4 套接字,我可以假设 accept(3) 返回 IPv4 地址吗?

转载 作者:行者123 更新时间:2023-12-02 05:41:01 25 4
gpt4 key购买 nike

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 - 如果我将它应用于 IPv4 套接字,我可以假设 accept(3) 返回 IPv4 地址吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10960918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com