gpt4 book ai didi

sockets - 了解套接字名称

转载 作者:行者123 更新时间:2023-12-03 11:54:31 27 4
gpt4 key购买 nike

Socket names are strings and appear in the file system name space through portals.



来自 http://publib.boulder.ibm.com/infocenter/aix/v7r1/index.jsp?topic=%2Fcom.ibm.aix.progcomm%2Fdoc%2Fprogcomc%2Fskt_comms.htm

The bind call is used to assign a name to a socket on the local side of a connection.



来自 http://osr507doc.sco.com/en/netguide/dusockD.binding_names.html
int bind(int socket, const struct sockaddr *address, socklen_t address_len);

从绑定(bind)的手册页。

套接字“名称”到底是什么?我们是否“设置”它们?

绑定(bind)系统调用似乎没有指定名称的参数,是吗?

最佳答案

实际上打开套接字的函数通常会返回一个句柄/标识符(套接字描述符)以供将来引用。
正如您发布的链接所述:

bind(s, name, namelen);

The argument s in the line above is the socket descriptor returned from the socket() call.

我认为这只是 socket descriptor 的自定义名称,因此是可选的。如果需要,可能还取决于您将要做什么。

关于sockets - 了解套接字名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7445108/

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