The IResponse::IsClientConnected method determines if the client has disconnected from the server since the last Response.Write operation.
HRESULT IsClientConnected(
  VARIANT_BOOL pfIsClientConnected  //pointer to a boolean that 
                                    // indicates whether or not the 
                                    // client is connected
);