Share via

WriteClient Function

The WriteClient function is a callback function that is supplied in the EXTENSION_CONTROL_BLOCK Structure 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 lpdwSizeofBuffer,
      DWORD dwSync


  • ConnID
    Specifies the 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.

  • dwSync
    Specifies a DWORD that contains flags that indicate how the I/O operation will be handled. Can be either of the following values.




    Indicates that the I/O operation should be done synchronously.


    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.


This function attempts to write the data in the supplied buffer to the same socket that was used for the client request. 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.

If you attempt to send more than 16 KB of data over an SSL connection, IIS will break your outgoing data into multiple chunks of 16 KB or smaller.

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 the ISAPI extension with EXTENSION_CONTROL_BLOCK, context value, number of bytes sent, and error codes, if any. It is the responsibility of the ISAPI extension to do further processing and finally use ServerSupportFunction with HSE_DONE_WITH_SESSION set to notify the server when it is finished processing the request.

Only one outstanding asynchronous I/O operation is permitted per request. This limitation applies to calls to asynchronous WriteClient, or to the asynchronous Win32 TransmitFile function through the HSE_REQ_TRANSMIT_FILE function of the ServerSupportFunction Function.


Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

Header: Declared in httpext.h.