Function anjay_serve

Function Documentation

int anjay_serve(anjay_t *anjay, avs_net_socket_t *ready_socket)

Reads a message from given ready_socket and handles it appropriately.

Initially, the receive method on the underlying socket is called with receive timeout set to zero. Subsequent receive requests may block with non-zero timeout values when e.g. waiting for retransmissions or subsequent BLOCK chunks - this is necessary to hide this complexity from the user callbacks in streaming mode.

This function may handle more than one request at once. Upon successful return, it is guaranteed that there is no more data to be received on the socket at the moment.

Parameters:
  • anjay – Anjay object to operate on.

  • ready_socket – A socket to read the message from.

Returns:

0 on success, a negative value in case of error. Note that it includes non-fatal errors, such as receiving a malformed packet.