Receiver
Engine » Link

## Functions

PN_EXTERN void | pn_link_flow (pn_link_t *receiver, int credit)
| Grant credit for incoming deliveries on a receiver. More...
PN_EXTERN void | pn_link_drain (pn_link_t *receiver, int credit)
| Grant credit for incoming deliveries on a receiver, and set drain mode to true. More...
PN_EXTERN void | pn_link_set_drain (pn_link_t *receiver, bool drain)
| Set the drain mode on a link. More...
PN_EXTERN ssize_t | pn_link_recv (pn_link_t *receiver, char *bytes, size_t n)
| Receive message data for the current delivery on a link. More...
PN_EXTERN bool | pn_link_draining (pn_link_t *receiver)
| Check if a link is currently draining. More...

## Detailed Description

## Function Documentation

## pn_link_drain()

PN_EXTERN void pn_link_drain | ( | pn_link_t * | receiver,
|  | int | credit
| ) |  |

Grant credit for incoming deliveries on a receiver, and set drain mode to true.

Use pn_link_set_drain to set the drain mode explicitly.

Parameters

  [in] | receiver | a receiving link object
  [in] | credit | the amount to increment the link credit

## pn_link_draining()

PN_EXTERN bool pn_link_draining | ( | pn_link_t * | receiver | ) |

Check if a link is currently draining.

A link is defined to be draining when drain mode is set to true, and the sender still has excess credit.

Parameters

  [in] | receiver | a receiving link object

Returns
  true if the link is currently draining, false otherwise

## pn_link_flow()

PN_EXTERN void pn_link_flow | ( | pn_link_t * | receiver,
|  | int | credit
| ) |  |

Grant credit for incoming deliveries on a receiver.

Parameters

  [in] | receiver | a receiving link object
  [in] | credit | the amount to increment the link credit

## pn_link_recv()

PN_EXTERN ssize_t pn_link_recv | ( | pn_link_t * | receiver,
|  | char * | bytes,
|  | size_t | n
| ) |  |

Receive message data for the current delivery on a link.

Use pn_delivery_pending on the current delivery to figure out how much buffer space is needed.

Note that the link API can be used to stream large messages across the network, so just because there is no data to read does not imply the message is complete. To ensure the entirety of the message data has been read, either invoke pn_link_recv until PN_EOS is returned, or verify that pn_delivery_partial is false, and pn_delivery_pending is 0.

Parameters

  [in] | receiver | a receiving link object
  [in] | bytes | a pointer to an empty buffer
  [in] | n | the buffer capacity

Returns
  the number of bytes received, PN_EOS, or an error code

## pn_link_set_drain()

PN_EXTERN void pn_link_set_drain | ( | pn_link_t * | receiver,
|  | bool | drain
| ) |  |

Set the drain mode on a link.

Parameters

  [in] | receiver | a receiving link object
  [in] | drain | the drain mode