WsAcceptChannel function (webservices.h)

Accepts the next incoming message from the specified listener.


HRESULT WsAcceptChannel(
  [in]           WS_LISTENER            *listener,
  [in]           WS_CHANNEL             *channel,
  [in, optional] const WS_ASYNC_CONTEXT *asyncContext,
  [in, optional] WS_ERROR               *error


[in] listener

Pointer to a WS_LISTENER structure representing the listener. This is the listener passed to WsCreateChannelForListener when the channel was created.

[in] channel

Pointer to a WS_CHANNEL structure representing the channel to accept.

[in, optional] asyncContext

Pointer to a WS_ASYNC_CONTEXT data structure with information for invoking the function asynchronously. Pass a NULL value for a synchronous operation.

[in, optional] error

Pointer to a WS_ERROR structure that receives additional error information 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 listener or channel was aborted.
The listener has faulted. See the Remarks section.
The listener or the channel or both were in an inappropriate state. See the Remarks section.
The connection with the remote endpoint was terminated.
The operation did not complete within the time allotted.
A quota was exceeded.
The input data was not in the expected format or did not have the expected value.
Insufficient memory to complete the operation.
One or more arguments are not valid.
Security verification was not successful for the received data.
A security operation failed in the Windows Web Services framework.
Other Errors
This function may return other errors not listed above.


Once you accept a channel, you must close it when you no longer need it and free the resources by calling the
WsCloseChannel function, and then calling either the WsFreeChannel or the WsResetChannel. function.

For WsAcceptChannel to succeed, the listener must be in WS_LISTENER_STATE_OPEN state, and the channel must be in WS_CHANNEL_STATE_CREATED state. For more information, see the WS_LISTENER_STATE and WS_CHANNEL_STATE enumerations.

If a listener is in the WS_LISTENER_STATE_FAULTED state,
WsAcceptChannel immediately returns the WS_E_OBJECT_FAULTED error code. If an application is calling WsAcceptChannel in a loop, the application must check for this error, so it can end the loop.


Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header webservices.h
Library WebServices.lib
DLL WebServices.dll