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 callingPR_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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论