PR_AcceptRead 编辑

Accepts a new connection and receives a block of data.

Syntax

#include <prio.h>

/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRInt32 PR_AcceptRead(
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc *listenSock,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc **acceptedSock,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr **peerAddr,
  void *buf,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRInt32 amount,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRIntervalTime timeout);

Parameters

The function has the following parameters:

listenSock
A pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc object representing a socket descriptor that has been called with the /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Listen function, also known as the rendezvous socket.
acceptedSock
A pointer to a pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc object. On return, *acceptedSock points to the /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc object for the newly connected socket. This parameter is valid only if the function return does not indicate failure.
peerAddr
A pointer a pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr object. On return, peerAddr points to the address of the remote socket. The /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr object that peerAddr points to will be in the buffer pointed to by buf. This parameter is valid only if the function return does not indicate failure.
buf
A pointer to a buffer to hold data sent by the peer and the peer's address. This buffer must be large enough to receive amount bytes of data and two /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr structures (thus allowing the runtime to align the addresses as needed).
amount
The number of bytes of data to receive. Does not include the size of the /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRNetAddr structures. If 0, no data will be read from the peer.
timeout
The timeout interval only applies to the read portion of the operation. PR_AcceptRead blocks indefinitely until the connection is accepted; the read will time out after the timeout interval elapses.

Returns

Description

PR_AcceptRead accepts a new connection and retrieves the newly created socket's descriptor and the connecting peer's address. Also, as its name suggests, PR_AcceptRead receives the first block of data sent by the peer.

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

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

发布评论

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

词条统计

浏览:95 次

字数:4647

最后编辑:7年前

编辑次数:0 次

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