PR_Bind 编辑

Binds an address to a specified socket.

Syntax

#include <prio.h>

/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRStatus PR_Bind(
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc *fd,
  const /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr *addr);

Parameters

The function has the following parameters:

fd
A pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc object representing a socket.
addr
A pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr object representing the address to which the socket will be bound.

Returns

The function returns one of the following values:

Description

When a new socket is created, it has no address bound to it. PR_Bind assigns the specified address (also known as name) to the socket. If you do not care about the exact IP address assigned to the socket, set the inet.ip field of /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr to PR_htonl(PR_INADDR_ANY). If you do not care about the TCP/UDP port assigned to the socket, set the inet.port field of /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr to 0.

Note that if /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Connect is invoked on a socket that is not bound, it implicitly binds an arbitrary address the socket.

Call /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_GetSockName to obtain the address (name) bound to a socket.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:78 次

字数:3531

最后编辑:6年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文