[riot-notifications] [RIOT-OS/RIOT] sock_dtls: add timeout to sock_dtls_send and sock_dtls_session_create (#14043)

Martine Lenders notifications at github.com
Wed May 13 13:34:00 CEST 2020

@miri64 requested changes on this pull request.

Nearly there.

> @@ -448,4 +463,9 @@ static void _session_to_ep(const session_t *session, sock_udp_ep_t *ep)
     memcpy(&ep->addr.ipv6, &session->addr, sizeof(ipv6_addr_t));
+static uint32_t _update_timeout(uint32_t start, uint32_t timeout) {

static inline uint32_t _update_timeout(uint32_t start, uint32_t timeout)

> @@ -390,10 +390,18 @@
  * After the UDP sock is created, we can proceed with creating the DTLS sock.
  * Before sending the packet, we must first create a session with the remote
- * endpoint using @ref sock_dtls_session_create(). If the handshake is
- * successful and the session is created, we send packets to it using
- * @ref sock_dtls_send(). If the packet is successfully sent, we listen for
- * the response with @ref sock_dtls_recv().
+ * endpoint using @ref sock_dtls_session_create(). We can set the timeout to `0`
+ * if we want the function returns immediately after starting the handshake.

This paragraph needs to be adapted now.

>   *
  * @return  0 on success
- * @return  -EAGAIN, if DTLS_HANDSHAKE_TIMEOUT is `0` and no data is available.
+ * @return  -EAGAIN, if @p timeout is `0` and handshake started.

What is the use case for this again considering `sock_async`? As we only have `CONN_RDY` (a locally initialized handshake was finished) and `CONN_RECV` (a session was initialized by a remote peer) as events to deal with, I don't see much value for `timeout=0`. Starting a process that is not finished in the function it self and does not have a dedicated function to finish it, seems very inconsistent to me (calling `sock_dtls_recv()` should, from a user perspective, only be used to receive data IMHO, not to finish a handshake that was started as a side-effect of a certain parameter being set to a certain value).

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200513/1163815e/attachment.htm>

More information about the notifications mailing list