Loading...
Searching...
No Matches
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  async.h
 Definitions for sock extension for asynchronous access.
 
file  types.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.
 
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.
 
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.
 
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.
 
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 flags, void *arg)
 Event callback for sock_udp_t.
 

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

bool sock_dtls_get_event_session (sock_dtls_t *sock, sock_dtls_session_t *session)
 Gets the asynchronous event session from sock object.
 
void sock_dtls_set_cb (sock_dtls_t *sock, sock_dtls_cb_t cb, void *cb_arg)
 Sets the asynchronous event context from sock object.
 
void sock_ip_set_cb (sock_ip_t *sock, sock_ip_cb_t cb, void *cb_arg)
 Sets event callback for sock_ip_t.
 
void sock_tcp_set_cb (sock_tcp_t *sock, sock_tcp_cb_t cb, void *cb_arg)
 Sets event callback for sock_tcp_t.
 
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.
 
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.
 
sock_async_ctx_tsock_dtls_get_async_ctx (sock_dtls_t *sock)
 Gets the asynchronous event context from sock object.
 
sock_async_ctx_tsock_ip_get_async_ctx (sock_ip_t *sock)
 Gets the asynchronous event context from sock object.
 
sock_async_ctx_tsock_tcp_get_async_ctx (sock_tcp_t *sock)
 Gets the asynchronous event context from sock object.
 
sock_async_ctx_tsock_tcp_queue_get_async_ctx (sock_tcp_queue_t *queue)
 Gets the asynchronous event context from TCP listening queue.
 
sock_async_ctx_tsock_udp_get_async_ctx (sock_udp_t *sock)
 Gets the asynchronous event context from sock object.
 

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_dtls_t

typedef struct sock_dtls sock_dtls_t

forward declare for async

Definition at line 47 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_ip_t

typedef struct sock_ip sock_ip_t

forward declare for async

Definition at line 73 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_tcp_queue_t

forward declare for async

Definition at line 97 of file types.h.

◆ sock_tcp_t

typedef struct sock_tcp sock_tcp_t

forward declare for async

Definition at line 96 of file types.h.

◆ sock_udp_cb_t

typedef void(* sock_udp_cb_t) (sock_udp_t *sock, sock_async_flags_t flags, 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.

◆ sock_udp_t

typedef struct sock_udp sock_udp_t

forward declare for async

Definition at line 139 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_get_event_session()

bool sock_dtls_get_event_session ( sock_dtls_t sock,
sock_dtls_session_t session 
)

Gets the asynchronous event session from sock object.

Precondition
(sock != NULL) && (session != NULL)
Note
Only available with SOCK_HAS_ASYNC defined. Should only be called within a DTLS event and session is only available for the event types SOCK_ASYNC_CONN_RDY and SOCK_ASYNC_CONN_FIN. For other event types use sock_dtls_recv() to get the session.
Parameters
[in]sockThe DTLS sock object of the current event.
[out]sessionSession object of the current event.
Returns
true if the event session is available, false otherwise.

◆ sock_dtls_set_cb()

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

Sets 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