WsCloseChannel function (webservices.h)
Closes a specified channel.
Syntax
HRESULT WsCloseChannel(
[in] WS_CHANNEL *channel,
[in, optional] const WS_ASYNC_CONTEXT *asyncContext,
[in, optional] WS_ERROR *error
);
Parameters
[in] channel
Pointer to a WS_CHANNEL structure representing the channel to close.
[in, optional] asyncContext
Pointer to a WS_ASYNC_CONTEXT data structure containing information for invoking the function asynchronously. Pass a NULL value to call the function synchronously.
[in, optional] error
Pointer to a WS_ERROR structure where additional error information is stored if the function fails.
Return value
If the function succeeds, it returns NO_ERROR; otherwise, it returns an HRESULT error code.
Return code | Description |
---|---|
|
The asynchronous operation is still pending. |
|
The channel closure was aborted by a call to WsAbortChannel while the channel was closing. |
|
The channel was in an inappropriate state (see the Remarks section). |
|
The connection with the remote endpoint was terminated. |
|
The remote endpoint could not process the request. |
|
The input data was not in the expected format or did not have the expected value. |
|
The operation did not complete within the time allotted. |
|
A quota was exceeded. |
|
Insufficient memory to complete the operation. |
|
One or more arguments are invalid. |
|
This function may return other errors not listed above. |
Remarks
If you open a channel or successfully accept a channel, you must close it when it is no longer needed. After a channel has been closed, the associated resources can safely be freed.
The channel-closing process will wait for any already initiated, pending I/O to complete.
If there are no messages currently being read or written for the channel, the channel attempts a graceful shutdown. Otherwise, all I/O still pending on the channel itself is aborted and the channel does a rude shutdown.
If the channel attempts a graceful shutdown but encounters an error, WsCloseChannel will return an error, but the channel will still be closed.
This operation is allowed only if the channel is in WS_CHANNEL_STATE_OPEN or WS_CHANNEL_STATE_FAULTED states.
Closing a channel automatically disassociates any messages that are in the process of being read or written. Therefore, it is not necessary to call WsAbandonMessage before calling WsCloseChannel).
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7 [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 R2 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | webservices.h |
Library | WebServices.lib |
DLL | WebServices.dll |