CHttpServerContext::TransmitFile

BOOL TransmitFile( HANDLE hFile**, DWORD** dwFlags = HSE_IO_DISCONNECT_AFTER_SEND, LPVOID pstrHeader = NULL, DWORD dwHeaderLen = 0, LPVOID pstrTrailer = NULL, DWORD dwTrailerLen = 0 );

Return Value

TRUE if the file's data was sent; otherwise, FALSE. To get extended error information, call . The function returns FALSE if an overlapped I/O operation is not complete before TransmitFile returns. In that case, GetLastError returns ERROR_IO_PENDING.

Parameters

hFile

A handle to the file containing the data to transmit. The file must have been opened with FILE_FLAG_SEQUENTIAL_SCAN and FILE_FLAG_OVERLAPPED.

dwFlags

The attributes associated with the file. By default, HSE_IO_DISCONNECT_AFTER_SEND. See in the Platform SDK for a list of possible attributes.

pstrHeader

A pointer to the string containing the header to send before transmitting the file's data. The header conveys to the receiving browser the type of data being sent and how it should be displayed. If NULL, the header is not sent.

dwHeaderLen

The length of the header. By default, 0. If pstrHeader is not NULL, and dwHeaderLen is 0, the function will use the Win32 function to find the length of the trailer. (In this case, pstrTrailer must be a null-terminated string.)

pstrTrailer

A pointer to the string containing the trailer to send after transmitting the file's data. If NULL, the trailer is not sent.

dwTrailerLen

The length of the trailer. By default, 0. If pstrTrailer is not NULL, and dwTrailerLen is 0, the function will use the Win32 function lstrlen to find the length of the trailer. (In this case, pstrTrailer must be a null-terminated string.)

Remarks

Call this member function to transmit a file to a requester. This member function performs the operations of the ServerSupportFunction command flag HSE_REQ_TRANSMIT_FILE. The server performs this operation asynchronously. The server submits this operation to its internal asynchronous I/O queue and returns to the caller. MFC alters the context object to return HSE_STATUS_PENDING, and will use HSE_DONE_WITH_SESSION when the callback indicates completion of the I/O. MFC also sets m_bSendHeaders in the context object FALSE, because headers are sent automatically.

See the sample for a demonstration of this member function.

CHttpServerContext OverviewClass MembersHierarchy Chart

See Also

CHttpServerContext::ServerSupportFunction