Loading...
Searching...
No Matches
Application I/O Handling
Application API

API for Application Input / Output checking. More...

Collaboration diagram for Application I/O Handling:

## Macros

#define | COAP_IO_WAIT 0
#define | COAP_IO_NO_WAIT ((uint32_t)-1)

## Functions

int | coap_io_process (coap_context_t *ctx, uint32_t timeout_ms)
| The main I/O processing function.
int | coap_io_process_with_fds (coap_context_t *ctx, uint32_t timeout_ms, int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
| The main message processing loop with additional fds for internal select.
int | coap_io_pending (coap_context_t *context)
| Check to see if there is any i/o pending for the `context`.

## Detailed Description

API for Application Input / Output checking.

## Macro Definition Documentation

## COAP_IO_NO_WAIT

#define COAP_IO_NO_WAIT ((uint32_t)-1)

Definition at line 572 of file coap_net.h.

## COAP_IO_WAIT

#define COAP_IO_WAIT 0

Definition at line 571 of file coap_net.h.

## Function Documentation

## coap_io_pending()

int coap_io_pending | ( | coap_context_t * | context | ) |

Check to see if there is any i/o pending for the `context`.

This includes Observe active (client) and partial large block transfers.

coap_io_process() is called internally to try to send outstanding data as well as process any packets just received.

Parameters

  context | The CoAP context.

Returns
  `1` I/O still pending, `0` no I/O pending.

Definition at line 1708 of file coap_io.c.

Here is the call graph for this function:

## coap_io_process()

int coap_io_process | ( | coap_context_t * | ctx,
|  | uint32_t | timeout_ms
| ) |  |

The main I/O processing function.

All pending network I/O is completed, and then optionally waits for the next input packet.

This internally calls coap_io_prepare_io(), then select() for the appropriate sockets, updates COAP_SOCKET_CAN_xxx where appropriate and then calls coap_io_do_io() before returning with the time spent in the function.

Alternatively, if libcoap is compiled with epoll support, this internally calls coap_io_prepare_epoll(), then epoll_wait() for waiting for any file descriptors that have (internally) been set up with epoll_ctl() and finally coap_io_do_epoll() before returning with the time spent in the function.

Parameters

  ctx | The CoAP context

  timeout_ms

  Minimum number of milliseconds to wait for new packets before returning after doing any processing. If COAP_IO_WAIT, the call will block until the next internal action (e.g. packet retransmit) if any, or block until the next packet is received whichever is the sooner and do the necessary processing. If COAP_IO_NO_WAIT, the function will return immediately after processing without waiting for any new input packets to arrive.

Returns
  Number of milliseconds spent in function or `-1` if there was an error

Definition at line 1524 of file coap_io.c.

Here is the call graph for this function:
Here is the caller graph for this function:

## coap_io_process_with_fds()

int coap_io_process_with_fds | ( | coap_context_t * | ctx,
|  | uint32_t | timeout_ms,
|  | int | nfds,
|  | fd_set * | readfds,
|  | fd_set * | writefds,
|  | fd_set * | exceptfds
| ) |  |

The main message processing loop with additional fds for internal select.

Parameters

  ctx | The CoAP context

  timeout_ms

  Minimum number of milliseconds to wait for new packets before returning after doing any processing. If COAP_IO_WAIT, the call will block until the next internal action (e.g. packet retransmit) if any, or block until the next packet is received whichever is the sooner and do the necessary processing. If COAP_IO_NO_WAIT, the function will return immediately after processing without waiting for any new input packets to arrive.

  nfds | The maximum FD set in readfds, writefds or exceptfds plus one,
  readfds | Read FDs to additionally check for in internal select() or NULL if not required.
  writefds | Write FDs to additionally check for in internal select() or NULL if not required.
  exceptfds | Except FDs to additionally check for in internal select() or NULL if not required.

Returns
  Number of milliseconds spent in coap_io_process_with_fds, or `-1` if there was an error. If defined, readfds, writefds, exceptfds are updated as returned by the internal select() call.

Definition at line 1529 of file coap_io.c.

Here is the call graph for this function:
Here is the caller graph for this function: