libcoap  4.3.0
Application I/O Handling

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

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. More...
 
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. More...
 

Detailed Description

API functions for Application Input / Output.

Macro Definition Documentation

◆ COAP_IO_NO_WAIT

#define COAP_IO_NO_WAIT   ((uint32_t)-1)

Definition at line 535 of file net.h.

◆ COAP_IO_WAIT

#define COAP_IO_WAIT   0

Definition at line 534 of file net.h.

Function Documentation

◆ 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
ctxThe CoAP context
timeout_msMinimum 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 1261 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
ctxThe CoAP context
timeout_msMinimum 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.
nfdsThe maximum FD set in readfds, writefds or exceptfds plus one,
readfdsRead FDs to additionally check for in internal select() or NULL if not required.
writefdsWrite FDs to additionally check for in internal select() or NULL if not required.
exceptfdsExcept 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 1266 of file coap_io.c.

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