pdcomm_tcp_stop
Function
Stops the endpoint and starts a graceful close.
PdcommStatus pdcomm_tcp_stop(PdcommTcpEndpoint *endpoint)In the SELECTED state the endpoint queues Separate.req. Every open transaction fails with #PDCOMM_TCP_CANCELLED, unanswered received primaries are dropped, and the state becomes #PDCOMM_TCP_STOPPED. The connection stays open for up to PdcommTcpOptions::shutdown_timeout_ms while pdcomm_tcp_poll() writes queued frames. Keep polling and draining events until PdcommTcpState::closed is 1. Calling it again while stopping has no effect.
Parameters
| Name | Description |
|---|---|
endpoint | Live endpoint. |
Returns
#PDCOMM_OK on success, including on an endpoint that was never started; #PDCOMM_INVALID_ARGUMENT when endpoint is NULL; #PDCOMM_BACKPRESSURE when an event is staged (see pdcomm_tcp_next_event()) or the event queue cannot hold the shutdown events; #PDCOMM_POISONED.
Notes
- When a GEM role is configured, the call also updates the GEM state.