1COAP_KEEPALIVE(3)               libcoap Manual               COAP_KEEPALIVE(3)
2
3
4

NAME

6       coap_keepalive, coap_context_set_keepalive - work with CoAP keepalive
7

SYNOPSIS

9       #include <coap2/coap.h>
10
11       void void coap_context_set_keepalive(coap_context_t *context, unsigned
12       int seconds);
13
14       Link with -lcoap-2, -lcoap-2-gnutls, -lcoap-2-openssl or
15       -lcoap-2-tinydtls depending on your (D)TLS library type.
16

DESCRIPTION

18       There may be a requirement to send out keepalive traffic when the CoAP
19       session is idle (no packets have been sent or received for a specified
20       period) to keep, say, an interim NAT device "warm" with the NAT
21       translation state, or to periodically check whether the device at the
22       other end of the session has "gone away".
23
24       For DTLS, this is done with the confirmable CoAP (0.00) Ping packet,
25       which solicits a CoAP RST response. For TLS, this is done with Coap
26       (7.02) Ping packet, which solicits a CoAP (7.03) Pong response, all
27       handled by libcoap.
28
29       The coap_context_set_keepalive() function needs to be called to update
30       the context with the keepalive for idle traffic timeout of seconds. If
31       seconds is set to 0, then the sending of keepalives is disabled. Any
32       sessions created from this context will use the same seconds value to
33       determine whether a keepalive "ping" is to be sent out or not.
34
35       Applications can track the usage of the receipt of "pings" and receipt
36       of "responses" by defining the respective handlers to use by using
37       coap_register_ping_handler() and coap_register_pong_handler().
38
39       If the keepalive fails to solicit a response, then this can be tracked
40       by defining the handler to use by using coap_register_nack_handler()
41       which will be called with a reason of COAP_NACK_TOO_MANY_RETRIES.
42
43           Note
44           coap_context_set_keepalive() is supported by both the CoAP client
45           and CoAP server.
46

SEE ALSO

48       coap_handler(3)
49

FURTHER INFORMATION

51       "RFC7252: The Constrained Application Protocol (CoAP)"
52
53       "RFC8323: CoAP (Constrained Application Protocol) over TCP, TLS, and
54       WebSockets"
55

BUGS

57       Please report bugs on the mailing list for libcoap:
58       libcoap-developers@lists.sourceforge.net
59

AUTHORS

61       The libcoap project <libcoap-developers@lists.sourceforge.net>
62
63
64
65coap_keepalive 4.2.1              02/24/2020                 COAP_KEEPALIVE(3)
Impressum