PR_TransmitFile
Sends a complete file across a connected socket.
Syntax
#include <prio.h>
PRInt32 PR_TransmitFile(
PRFileDesc *networkSocket,
PRFileDesc *sourceFile,
const void *headers,
PRInt32 hlen,
PRTransmitFileFlags flags,
PRIntervalTime timeout);
Parameters
The function has the following parameters:
networkSocketA pointer to a PRFileDesc object representing the connected socket to send data over.
sourceFileA pointer to a PRFileDesc object representing the file to send.
headersA pointer to the buffer holding the headers to be sent before sending data.
hlenLength of the
headersbuffer in bytes.flagsOne 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.
timeoutTime 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_SOCKETflag 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;