Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
COAP_KEEPALIVE(3)		 libcoap Manual 	       COAP_KEEPALIVE(3)

NAME
     coap_keepalive, coap_context_set_keepalive - Work with CoAP keepalive

SYNOPSIS
     #include <coap3/coap.h>

     void  coap_context_set_keepalive(coap_context_t *context, unsigned int sec-
     onds);

     For  specific   (D)TLS   library	support,   link   with	 -lcoap-3-notls,
     -lcoap-3-gnutls,  -lcoap-3-openssl,  -lcoap-3-mbedtls,  -lcoap-3-wolfssl or
     -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default  (D)TLS
     library support.

DESCRIPTION
     There may be a requirement to send out keepalive traffic when the CoAP ses-
     sion is idle (no packets have been sent or received for a specified period)
     to  keep, say, an interim NAT device "warm" with the NAT translation state,
     or to periodically check whether the device at the other end of the session
     has "gone away".

     For UDP/DTLS, this is done with the confirmable CoAP  (0.00)  Ping  packet,
     which  solicits  a  CoAP  RST response. For TCP/TLS, this is done with CoAP
     (7.02) Ping packet, which solicits a CoAP (7.03) Pong response, all handled
     by libcoap.

FUNCTIONS
     Function: coap_context_set_keepalive()

     The coap_context_set_keepalive() function needs to be called to update  the
     context  with the keepalive for idle traffic timeout of seconds. If seconds
     is set to 0 (the default), then the sending of keepalives is disabled.  Any
     sessions  created	from this context will use the same seconds value to de-
     termine whether a keepalive "ping" is to be sent out or not.

     Applications can track the usage of the receipt of "pings" and  receipt  of
     "responses" by defining the respective handlers to use by using coap_regis-
     ter_ping_handler() and coap_register_pong_handler().

     If  the  keepalive fails to solicit a response, then this can be tracked by
     defining the handler to use by  using  coap_register_event_handler()  which
     will be called with a reason of COAP_EVENT_KEEPALIVE_FAILURE.

     NOTE:  As	this may be used to keep an interim NAT device "warm", the expo-
     nentially increasing retransmit times for CON requests is limited	to  sec-
     onds,  but  the  retransmit counter is not affected. Unless needed, seconds
     shold not be set to less than 30.

SEE ALSO
     coap_handler(3)

FURTHER INFORMATION
     See

     "RFC7252: The Constrained Application Protocol (CoAP)"

     "RFC8323: CoAP (Constrained Application Protocol) over TCP, TLS,  and  Web-
     Sockets"

     for further information.

BUGS
     Please  raise  an issue on GitHub at https://github.com/obgm/libcoap/issues
     to report any bugs.

     Please raise a Pull Request  at  https://github.com/obgm/libcoap/pulls  for
     any fixes.

AUTHORS
     The libcoap project <libcoap-developers@lists.sourceforge.net>

coap_keepalive 4.3.5		   08/02/2026		       COAP_KEEPALIVE(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=coap_keepalive&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help