PR_Accept 编辑

Accepts a connection on a specified socket.

Syntax

#include <prio.h>

/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc* PR_Accept(
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc *fd,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr *addr,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRIntervalTime timeout);

Parameters

The function has the following parameters:

fd
A pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc object representing the rendezvous socket on which the caller is willing to accept new connections.
addr
A pointer to a structure of type /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr. On output, this structure contains the address of the connecting entity.
timeout
A value of type /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRIntervalTime specifying the time limit for completion of the accept operation.

Returns

The function returns one of the following values:

Description

The socket fd is a rendezvous socket that has been bound to an address with /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Bind and is listening for connections after a call to /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Listen. PR_Accept accepts the first connection from the queue of pending connections and creates a new socket for the newly accepted connection. The rendezvous socket can still be used to accept more connections.

If the addr parameter is not NULL, PR_Accept stores the address of the connecting entity in the /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr object pointed to by addr.

PR_Accept blocks the calling thread until either a new connection is successfully accepted or an error occurs. If the timeout parameter is not PR_INTERVAL_NO_TIMEOUT and no pending connection can be accepted before the time limit, PR_Accept returns NULL with the error code PR_IO_TIMEOUT_ERROR.

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

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

发布评论

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

词条统计

浏览:43 次

字数:3898

最后编辑:6 年前

编辑次数:0 次

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