libcoap 4.3.5-develop-72190a8
|
API for Application Input / Output checking. More...
Macros | |
#define | COAP_IO_WAIT 0 |
#define | COAP_IO_NO_WAIT ((uint32_t)-1) |
Functions | |
COAP_API int | coap_io_process (coap_context_t *ctx, uint32_t timeout_ms) |
The main I/O processing function. | |
COAP_API 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. | |
COAP_API int | coap_io_pending (coap_context_t *context) |
Check to see if there is any i/o pending for the context . | |
COAP_API unsigned int | coap_io_prepare_io (coap_context_t *ctx, coap_socket_t *sockets[], unsigned int max_sockets, unsigned int *num_sockets, coap_tick_t now) |
Iterates through all the coap_socket_t structures embedded in endpoints or sessions associated with the ctx to determine which are wanting any read, write, accept or connect I/O (COAP_SOCKET_WANT_xxx is set). | |
COAP_API void | coap_io_do_io (coap_context_t *ctx, coap_tick_t now) |
Processes any outstanding read, write, accept or connect I/O as indicated in the coap_socket_t structures (COAP_SOCKET_CAN_xxx set) embedded in endpoints or sessions associated with ctx . | |
COAP_API unsigned int | coap_io_prepare_epoll (coap_context_t *ctx, coap_tick_t now) |
Any now timed out delayed packet is transmitted, along with any packets associated with requested observable response. | |
COAP_API void | coap_io_do_epoll (coap_context_t *ctx, struct epoll_event *events, size_t nevents) |
Process all the epoll events. | |
COAP_API coap_fd_t | coap_socket_get_fd (coap_socket_t *socket) |
Get the libcoap internal file descriptor for a socket. | |
COAP_API unsigned int | coap_io_get_fds (coap_context_t *context, coap_fd_t read_fds[], unsigned int *have_read_fds, unsigned int max_read_fds, coap_fd_t write_fds[], unsigned int *have_write_fds, unsigned int max_write_fds, unsigned int *rem_timeout_ms) |
COAP_API coap_socket_flags_t | coap_socket_get_flags (coap_socket_t *socket) |
Get the libcoap internal flags for a socket. | |
COAP_API void | coap_socket_set_flags (coap_socket_t *socket, coap_socket_flags_t flags) |
Set the libcoap internal flags for a socket. | |
API for Application Input / Output checking.
#define COAP_IO_NO_WAIT ((uint32_t)-1) |
Definition at line 663 of file coap_net.h.
#define COAP_IO_WAIT 0 |
Definition at line 662 of file coap_net.h.
COAP_API void coap_io_do_epoll | ( | coap_context_t * | ctx, |
struct epoll_event * | events, | ||
size_t | nevents | ||
) |
Process all the epoll events.
Note: If epoll support is compiled into libcoap, coap_io_do_epoll() must be used instead of coap_io_do_io().
Internal function
ctx | The current CoAP context. |
events | The list of events returned from an epoll_wait() call. |
nevents | The number of events. |
Definition at line 2517 of file coap_net.c.
COAP_API void coap_io_do_io | ( | coap_context_t * | ctx, |
coap_tick_t | now | ||
) |
Processes any outstanding read, write, accept or connect I/O as indicated in the coap_socket_t structures (COAP_SOCKET_CAN_xxx set) embedded in endpoints or sessions associated with ctx
.
Note: If epoll support is compiled into libcoap, coap_io_do_epoll() must be used instead of coap_io_do_io().
Internal function.
ctx | The CoAP context |
now | Current time |
Definition at line 2456 of file coap_net.c.
COAP_API unsigned int coap_io_get_fds | ( | coap_context_t * | context, |
coap_fd_t | read_fds[], | ||
unsigned int * | have_read_fds, | ||
unsigned int | max_read_fds, | ||
coap_fd_t | write_fds[], | ||
unsigned int * | have_write_fds, | ||
unsigned int | max_write_fds, | ||
unsigned int * | rem_timeout_ms | ||
) |
COAP_API 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.
context | The CoAP context. |
1
I/O still pending, 0
no I/O pending. Definition at line 1976 of file coap_io.c.
COAP_API unsigned int coap_io_prepare_epoll | ( | coap_context_t * | ctx, |
coap_tick_t | now | ||
) |
Any now timed out delayed packet is transmitted, along with any packets associated with requested observable response.
In addition, it returns when the next expected I/O is expected to take place (e.g. a packet retransmit).
Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll() must be used instead of coap_io_prepare_io().
Internal function.
ctx | The CoAP context |
now | Current time. |
Definition at line 1246 of file coap_io.c.
COAP_API unsigned int coap_io_prepare_io | ( | coap_context_t * | ctx, |
coap_socket_t * | sockets[], | ||
unsigned int | max_sockets, | ||
unsigned int * | num_sockets, | ||
coap_tick_t | now | ||
) |
Iterates through all the coap_socket_t structures embedded in endpoints or sessions associated with the ctx
to determine which are wanting any read, write, accept or connect I/O (COAP_SOCKET_WANT_xxx is set).
If set, the coap_socket_t is added to the sockets
.
Any now timed out delayed packet is transmitted, along with any packets associated with requested observable response.
In addition, it returns when the next expected I/O is expected to take place (e.g. a packet retransmit).
Prior to calling coap_io_do_io(), the sockets
must be tested to see if any of the COAP_SOCKET_WANT_xxx have the appropriate information and if so, COAP_SOCKET_CAN_xxx is set. This typically will be done after using a select() call.
Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll() must be used instead of coap_io_prepare_io().
Internal function.
ctx | The CoAP context |
sockets | Array of socket descriptors, filled on output |
max_sockets | Size of socket array. |
num_sockets | Pointer to the number of valid entries in the socket arrays on output. |
now | Current time. |
Definition at line 1307 of file coap_io.c.
COAP_API 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.
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. |
-1
if there was an error Definition at line 1726 of file coap_io.c.
COAP_API 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.
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. |
-1
if there was an error. If defined, readfds, writefds, exceptfds are updated as returned by the internal select() call. Definition at line 1741 of file coap_io.c.
COAP_API coap_fd_t coap_socket_get_fd | ( | coap_socket_t * | socket | ) |
Get the libcoap internal file descriptor for a socket.
This can be used to integrate libcoap in an external event loop instead of using one of its builtin event loops.
socket | The CoAP socket |
COAP_INVALID_SOCKET
if the platform is not using file descriptors. COAP_API coap_socket_flags_t coap_socket_get_flags | ( | coap_socket_t * | socket | ) |
COAP_API void coap_socket_set_flags | ( | coap_socket_t * | socket, |
coap_socket_flags_t | flags | ||
) |