Sock extension for asynchronous access

Provides backend functionality for asynchronous sock access. More...

Detailed Description

Provides backend functionality for asynchronous sock access.

Warning
This feature is experimental!
This API extension is still under development and should not be used in production yet.

Files

file  types.h
 Definitions for sock extension for asynchronous access.
 
file  async.h
 Definitions for sock extension for asynchronous access.
 

Typedefs

typedef struct sock_dtls sock_dtls_t
 forward declare for async
 
typedef void(* sock_dtls_cb_t) (sock_dtls_t *sock, sock_async_flags_t flags, void *arg)
 Event callback for sock_dtls_t. More...
 
typedef struct sock_ip sock_ip_t
 forward declare for async
 
typedef void(* sock_ip_cb_t) (sock_ip_t *sock, sock_async_flags_t flags, void *arg)
 Event callback for sock_ip_t. More...
 
typedef struct sock_tcp sock_tcp_t
 forward declare for async
 
typedef struct sock_tcp_queue sock_tcp_queue_t
 forward declare for async
 
typedef void(* sock_tcp_cb_t) (sock_tcp_t *sock, sock_async_flags_t flags, void *arg)
 Event callback for sock_tcp_t. More...
 
typedef void(* sock_tcp_queue_cb_t) (sock_tcp_queue_t *queue, sock_async_flags_t flags, void *arg)
 Event callback for sock_tcp_queue_t. More...
 
typedef struct sock_udp sock_udp_t
 forward declare for async
 
typedef void(* sock_udp_cb_t) (sock_udp_t *sock, sock_async_flags_t type, void *arg)
 Event callback for sock_udp_t. More...
 

Enumerations

enum  sock_async_flags_t {
  SOCK_ASYNC_CONN_RDY = 0x0001, SOCK_ASYNC_CONN_FIN = 0x0002, SOCK_ASYNC_CONN_RECV = 0x0004, SOCK_ASYNC_MSG_RECV = 0x0010,
  SOCK_ASYNC_MSG_SENT = 0x0020, SOCK_ASYNC_PATH_PROP = 0x0040
}
 Flag types to signify asynchronous sock events. More...
 

Functions

void sock_dtls_set_cb (sock_dtls_t *sock, sock_dtls_cb_t cb, void *cb_arg)
 Gets the asynchronous event context from sock object. More...
 
void sock_ip_set_cb (sock_ip_t *sock, sock_ip_cb_t cb, void *cb_arg)
 Sets event callback for sock_ip_t. More...
 
void sock_tcp_set_cb (sock_tcp_t *sock, sock_tcp_cb_t cb, void *cb_arg)
 Sets event callback for sock_tcp_t. More...
 
void sock_tcp_queue_set_cb (sock_tcp_queue_t *queue, sock_tcp_queue_cb_t cb, void *cb_arg)
 Sets event callback for sock_tcp_queue_t. More...
 
void sock_udp_set_cb (sock_udp_t *sock, sock_udp_cb_t cb, void *cb_arg)
 Gets the asynchronous event context from sock object. More...
 
sock_async_ctx_tsock_dtls_get_async_ctx (sock_dtls_t *sock)
 Gets the asynchronous event context from sock object. More...
 
sock_async_ctx_tsock_ip_get_async_ctx (sock_ip_t *sock)
 Gets the asynchronous event context from sock object. More...
 
sock_async_ctx_tsock_tcp_get_async_ctx (sock_tcp_t *sock)
 Gets the asynchronous event context from sock object. More...
 
sock_async_ctx_tsock_tcp_queue_get_async_ctx (sock_tcp_queue_t *queue)
 Gets the asynchronous event context from TCP listening queue. More...
 
sock_async_ctx_tsock_udp_get_async_ctx (sock_udp_t *sock)
 Gets the asynchronous event context from sock object. More...
 

Typedef Documentation

◆ sock_dtls_cb_t

typedef void(* sock_dtls_cb_t) (sock_dtls_t *sock, sock_async_flags_t flags, void *arg)

Event callback for sock_dtls_t.

Precondition
(sock != NULL)
Note
Only applicable with SOCK_HAS_ASYNC defined.
Parameters
[in]sockThe sock the event happened on
[in]flagsThe event flags. Expected values are
[in]argArgument provided when setting the callback using sock_dtls_set_cb(). May be NULL.

Definition at line 68 of file types.h.

◆ sock_ip_cb_t

typedef void(* sock_ip_cb_t) (sock_ip_t *sock, sock_async_flags_t flags, void *arg)

Event callback for sock_ip_t.

Precondition
(sock != NULL)
Note
Only applicable with SOCK_HAS_ASYNC defined.
Parameters
[in]sockThe sock the event happened on
[in]flagsThe event flags. Expected values are
[in]argArgument provided when setting the callback using sock_ip_set_cb(). May be NULL.

Definition at line 91 of file types.h.

◆ sock_tcp_cb_t

typedef void(* sock_tcp_cb_t) (sock_tcp_t *sock, sock_async_flags_t flags, void *arg)

Event callback for sock_tcp_t.

Precondition
(sock != NULL)
Note
Only applicable with SOCK_HAS_ASYNC defined.
Parameters
[in]sockThe sock the event happened on
[in]flagsThe event flags. Expected values are
[in]argArgument provided when setting the callback using sock_tcp_set_cb(). May be NULL.

Definition at line 117 of file types.h.

◆ sock_tcp_queue_cb_t

typedef void(* sock_tcp_queue_cb_t) (sock_tcp_queue_t *queue, sock_async_flags_t flags, void *arg)

Event callback for sock_tcp_queue_t.

Precondition
(queue != NULL)
Note
Only applicable with SOCK_HAS_ASYNC defined.
Parameters
[in]queueThe TCP listening queue the event happened on
[in]flagsThe event flags. The only expected value is SOCK_ASYNC_CONN_RECV.
[in]argArgument provided when setting the callback using sock_tcp_queue_set_cb(). May be NULL.

Definition at line 133 of file types.h.

◆ sock_udp_cb_t

typedef void(* sock_udp_cb_t) (sock_udp_t *sock, sock_async_flags_t type, void *arg)

Event callback for sock_udp_t.

Precondition
(sock != NULL)
Note
Only applicable with SOCK_HAS_ASYNC defined.
Parameters
[in]sockThe sock the event happened on
[in]flagsThe event flags. Expected values are
[in]argArgument provided when setting the callback using sock_udp_set_cb(). May be NULL.

Definition at line 157 of file types.h.

Enumeration Type Documentation

◆ sock_async_flags_t

Flag types to signify asynchronous sock events.

Note
Only applicable with SOCK_HAS_ASYNC defined.
Enumerator
SOCK_ASYNC_CONN_RDY 

Connection ready event.

SOCK_ASYNC_CONN_FIN 

Connection finished event.

SOCK_ASYNC_CONN_RECV 

Listener received connection event.

SOCK_ASYNC_MSG_RECV 

Message received event.

SOCK_ASYNC_MSG_SENT 

Message sent event.

SOCK_ASYNC_PATH_PROP 

Path property changed event.

Definition at line 37 of file types.h.

Function Documentation

◆ sock_dtls_get_async_ctx()

sock_async_ctx_t* sock_dtls_get_async_ctx ( sock_dtls_t sock)

Gets the asynchronous event context from sock object.

Precondition
(sock != NULL)
Note
Only available with SOCK_HAS_ASYNC and SOCK_HAS_ASYNC_CTX defined.
See also
SOCK_HAS_ASYNC_CTX
Parameters
[in]sockA DTLS sock object.
Returns
The asynchronous event context

◆ sock_dtls_set_cb()

void sock_dtls_set_cb ( sock_dtls_t sock,
sock_dtls_cb_t  cb,
void *  cb_arg 
)

Gets the asynchronous event context from sock object.

Precondition
(sock != NULL)
Warning
Never handle the callback in the caller's context! You might block the operation of the network stack or the DTLS library with that.
Note
Only available with SOCK_HAS_ASYNC defined.
Parameters
[in]sockA DTLS sock object.
[in]cbAn event callback. May be NULL to unset event callback.
[in]cb_argArgument to provide to cb. May be NULL.

◆ sock_ip_get_async_ctx()

sock_async_ctx_t* sock_ip_get_async_ctx ( sock_ip_t sock)

Gets the asynchronous event context from sock object.

Precondition
(sock != NULL)
Note
Only available with SOCK_HAS_ASYNC and SOCK_HAS_ASYNC_CTX defined.
See also
SOCK_HAS_ASYNC_CTX
Parameters
[in]sockA raw IPv4/IPv6 sock object.
Returns
The asynchronous event context

◆ sock_ip_set_cb()

void sock_ip_set_cb ( sock_ip_t sock,
sock_ip_cb_t  cb,
void *  cb_arg 
)

Sets event callback for sock_ip_t.

Precondition
(sock != NULL)
Warning
Never handle the callback in the caller's context! You might block the operation of the network stack with that.
Note
Only available with SOCK_HAS_ASYNC defined.
Parameters
[in]sockA raw IPv4/IPv6 sock object.
[in]cbAn event callback. May be NULL to unset event callback.
[in]cb_argArgument to provide to cb. May be NULL.

◆ sock_tcp_get_async_ctx()

sock_async_ctx_t* sock_tcp_get_async_ctx ( sock_tcp_t sock)

Gets the asynchronous event context from sock object.

Precondition
(sock != NULL)
Note
Only available with SOCK_HAS_ASYNC and SOCK_HAS_ASYNC_CTX defined.
See also
SOCK_HAS_ASYNC_CTX
Parameters
[in]sockA TCP sock object.
Returns
The asynchronous event context

◆ sock_tcp_queue_get_async_ctx()

sock_async_ctx_t* sock_tcp_queue_get_async_ctx ( sock_tcp_queue_t queue)

Gets the asynchronous event context from TCP listening queue.

Precondition
(queue != NULL)
Note
Only available with SOCK_HAS_ASYNC and SOCK_HAS_ASYNC_CTX defined.
See also
SOCK_HAS_ASYNC_CTX
Parameters
[in]queueA TCP listening queue.
Returns
The asynchronous event context

◆ sock_tcp_queue_set_cb()

void sock_tcp_queue_set_cb ( sock_tcp_queue_t queue,
sock_tcp_queue_cb_t  cb,
void *  cb_arg 
)

Sets event callback for sock_tcp_queue_t.

Precondition
(sock != NULL)
Warning
Never handle the callback in the caller's context! You might block the operation of the network stack with that.
Note
Only available with SOCK_HAS_ASYNC defined.
Parameters
[in]queueA TCP listening queue.
[in]cbAn event callback. May be NULL to unset event callback.
[in]cb_argArgument to provide to cb. May be NULL.

◆ sock_tcp_set_cb()

void sock_tcp_set_cb ( sock_tcp_t sock,
sock_tcp_cb_t  cb,
void *  cb_arg 
)

Sets event callback for sock_tcp_t.

Precondition
(sock != NULL)
Warning
Never handle the callback in the caller's context! You might block the operation of the network stack with that.
Note
Only available with SOCK_HAS_ASYNC defined.
Parameters
[in]sockA TCP sock object.
[in]cbAn event callback. May be NULL to unset event callback.
[in]cb_argArgument to provide to cb. May be NULL.

◆ sock_udp_get_async_ctx()

sock_async_ctx_t* sock_udp_get_async_ctx ( sock_udp_t sock)

Gets the asynchronous event context from sock object.

Precondition
(sock != NULL)
Note
Only available with SOCK_HAS_ASYNC and SOCK_HAS_ASYNC_CTX defined.
See also
SOCK_HAS_ASYNC_CTX
Parameters
[in]sockA UDP sock object.
Returns
The asynchronous event context

◆ sock_udp_set_cb()

void sock_udp_set_cb ( sock_udp_t sock,
sock_udp_cb_t  cb,
void *  cb_arg 
)

Gets the asynchronous event context from sock object.

Precondition
(sock != NULL)
Warning
Never handle the callback in the caller's context! You might block the operation of the network stack with that.
Note
Only available with SOCK_HAS_ASYNC defined.
Parameters
[in]sockA UDP sock object.
[in]cbAn event callback. May be NULL to unset event callback.
[in]cb_argArgument to provide to cb