WriteClient

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     
);
 

Parameters

ConnID
Specifies the logical connection identifier of the client to which the response data should be sent.
Buffer
Points to the data to be sent.
lpdwSizeofBuffer
Points to a DWORD that contains the number of bytes from the buffer that will be written to the client when the call is made. The DWORD also contains the number of bytes successfully sent out for synchronous write operations. For asynchronous write operations the returned value has no meaning.
dwReserved
Specifies a DWORD that contains flags which indicates how the I/O operation should be handled. Can be either of the following values.
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.

Return Values

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.

Remarks

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.