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
WS_S_ASYNC
The asynchronous operation is still pending.
WS_E_OPERATION_ABORTED
The channel closure was aborted by a call to WsAbortChannel while the channel was closing.
WS_E_INVALID_OPERATION
The channel was in an inappropriate state (see the Remarks section).
WS_E_ENDPOINT_DISCONNECTED
The connection with the remote endpoint was terminated.
WS_E_ENDPOINT_FAILURE
The remote endpoint could not process the request.
WS_E_INVALID_FORMAT
The input data was not in the expected format or did not have the expected value.
WS_E_OPERATION_TIMED_OUT
The operation did not complete within the time allotted.
WS_E_QUOTA_EXCEEDED
A quota was exceeded.
E_OUTOFMEMORY
Insufficient memory to complete the operation.
E_INVALIDARG
One or more arguments are invalid.
Other Errors
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

   
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