The WriteClient function is a callback function that is supplied in the ECB (EXTENSION_CONTROL_BLOCK) for a request sent to the ISAPI extension. It sends the data present in the given buffer to the client that made the request.
BOOL WriteClient(
HCONN ConnID,
LPVOID Buffer,
LPDWORD lpdwBytes,
DWORD dwReserved
);
Value | Meaning |
---|---|
HSE_IO_SYNC | Indicates that the I/O operation should be done synchronously |
HSE_IO_ASYNC | Indicates that the I/O operation should be done asynchronously. The ISAPI extension should have made a call to ServerSupportFunction( HSE_REQ_IO_COMPLETION) and submitted a callback function and context value for handling completion of asynchronous operations. |
If the function succeeds, the return value is TRUE. If an error occurs, the return value is FALSE. The Win32® GetLastError function can be called to determine the cause of the error.
This function attempts to write the data in the supplied buffer to the socket in which the client request came in. For synchronous writes, it attempts to write in the calling thread. The thread may become blocked while trying to send the data to client. On completion, WriteClient returns the number of bytes sent in *lpdwBytes.
For asynchronous writes, WriteClient submits the write operation to the system asynchronously and returns from the call immediately. At this point the ISAPI extension may choose to do more background processing or return from the HttpExtensionProc function with a HSE_STATUS_PENDING. When the I/O operation completes, the server calls the callback function submitted by ISA with the ECB, context value, number of bytes sent and error codes, if any. It is the responsibility of ISA to do further processing and finally use ServerSupportFunction with HSE_DONE_WITH_SESSION set to notify the server when it is done processing the request.
Only one outstanding asynchronous I/O operation is permitted per request. This includes an asynchronous WriteClient, an asynchronous TransmitFile, or a ServerSupportFunction call with the HSE_REQ_SEND_URL value set.