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

Aiman Ismail notifications at github.com
Fri May 8 12:55:52 CEST 2020


### Contribution description

This PR adds the `timeout` parameter to `sock_dtls_send()` and `sock_dtls_session_create()`, enabling user to set their own timeout to use. It is also part of work to add async support as described by https://github.com/RIOT-OS/RIOT/pull/12907#issuecomment-625289418.

### Testing procedure

Make sure the documentation makes sense and understandable.

With each one node as client and server, change the timeout value of `sock_dtls_session_create()` and `sock_dtls_send()` in client/server of `examples/dtls-sock`:

- These values should have no problem:
    - default values working
    - `sock_dtls_send` in client to 0
    - `sock_dtls_send` in server to 0

- These should fail:
    - `sock_dtls_session_create` in client to 0; ClientHello sent, returned error code `-11 (-EAGAIN)`
    - in client, comment out following code and set `sock_dtls_send` timeout to `SOCK_NO_TIMEOUT`: client will block. `sock_dtls_recv()` need to be called to from other thread that is not blocked to receive handshake messages from server.

```C
    // res = sock_dtls_session_create(&dtls_sock, &remote, &session, SOCK_NO_TIMEOUT);
    // if (res < 0) {
    //     printf("Error creating session: %d\n", (int)res);
    //     sock_dtls_close(&dtls_sock);
    //     sock_udp_close(&udp_sock);
    //     return -1;
    // }
```

### Issues/PRs references

#12907 

You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/14043

-- Commit Summary --

  * sock_dtls: add timeout to session create and send
  * examples/dtls-sock: add timeout to session create and send

-- File Changes --

    M examples/dtls-sock/dtls-client.c (6)
    M examples/dtls-sock/dtls-server.c (2)
    M pkg/tinydtls/contrib/sock_dtls.c (45)
    M sys/include/net/sock/dtls.h (50)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/14043.patch
https://github.com/RIOT-OS/RIOT/pull/14043.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/14043
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200508/9ccf06d2/attachment.htm>


More information about the notifications mailing list