PR_TransmitFile 编辑

Sends a complete file across a connected socket.

Syntax

#include <prio.h>

/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRInt32 PR_TransmitFile(
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc *networkSocket,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc *sourceFile,
  const void *headers,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRInt32 hlen,
  PRTransmitFileFlags flags,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRIntervalTime timeout);

Parameters

The function has the following parameters:

networkSocket
A pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc object representing the connected socket to send data over.
sourceFile
A pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileDesc object representing the file to send.
headers
A pointer to the buffer holding the headers to be sent before sending data.
hlen
Length of the headers buffer in bytes.
flags
One of the following flags:
  • PR_TRANSMITFILE_KEEP_OPEN indicates that the socket will be kept open after the data is sent.
  • PR_TRANSMITFILE_CLOSE_SOCKET indicates that the connection should be closed immediately after successful transfer of the file.
timeout
Time limit for completion of the transmit operation.

Returns

  • A positive number indicates the number of bytes successfully written, including both the headers and the file.
  • The value -1 indicates a failure. If an error occurs while sending the file, the PR_TRANSMITFILE_CLOSE_SOCKET flag is ignored. The reason for the failure can be obtained by calling PR_GetError.

Description

The PR_TransmitFile function sends a complete file (sourceFile) across a connected socket (networkSocket). If headers is non-NULL, PR_TransmitFile sends the headers across the socket before sending the file.

The enumeration PRTransmitFileFlags, used in the flags parameter, is defined as follows:

typedef enum PRTransmitFileFlags {
  PR_TRANSMITFILE_KEEP_OPEN = 0,
  PR_TRANSMITFILE_CLOSE_SOCKET = 1
} PRTransmitFileFlags;

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

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

发布评论

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

词条统计

浏览:96 次

字数:3503

最后编辑:8年前

编辑次数:0 次

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