Skip to content
Start free evaluation

pdcomm_tcp_reply

Function

Submits the reply to a received primary that has the W-bit set.

PdcommStatus pdcomm_tcp_reply(PdcommTcpEndpoint *endpoint, const PdcommTcpEvent *primary, uint8_t stream, uint8_t function, uint8_t wait, const uint8_t *body, size_t body_length)

Declared in: #include <pdcomm_tcp.h>

The reply reuses the primary's system bytes. Each W-bit primary occupies one of #PDCOMM_TCP_MAX_TRANSACTIONS incoming slots until you reply or the connection is deselected or closed, so reply to every one. The body is validated and copied. Success means only that the reply was queued.

Parameters

NameDescription
endpointLive endpoint in the #PDCOMM_TCP_SELECTED state.
primaryThe #PDCOMM_TCP_RECEIVED event of the primary, from this endpoint and the current generation. It is only read.
streamSECS-II stream; must equal the primary's stream.
functionThe primary's function plus 1, or 0 for an SxF0 abort reply.
waitMust be 0, because a reply cannot set the W-bit.
bodyOne complete encoded SECS-II item, or NULL with body_length 0 for a reply without a body.
body_lengthNumber of bytes at body; at most PdcommTcpOptions::max_frame_bytes minus 14.

Returns

#PDCOMM_OK when the reply was queued; #PDCOMM_INVALID_ARGUMENT when endpoint or primary is NULL, primary is not a received primary, the primary has no W-bit or was already answered, stream, function, or wait does not form a valid reply, or body is NULL with a nonzero length; #PDCOMM_STALE_TOKEN when primary comes from another endpoint or an earlier generation; #PDCOMM_INVALID_DATA for an invalid body; #PDCOMM_LIMIT_EXCEEDED when the body exceeds item_limits or does not fit in a frame; #PDCOMM_INVALID_STATE when the endpoint is not SELECTED; #PDCOMM_BACKPRESSURE when an event is staged, a queue is full, or the endpoint is stopping; #PDCOMM_POISONED.