GNUTLS_TRANSPORT_SET_PULL_TIMEOUT_FUNCTION(3)

πŸ’– gnutls_transport_set_pull_timeout_function(3) πŸ’–

okay bestie, welcome to the gnutls manual, the gnutls_transport_set_pull_timeout_function page, and honestly? this one is a bop once you get the vibe. it's an API function, it lives in the gnutls family, and it's giving "tell gnutls how to wait for data without just yolo-ing forever." let's get into it 🫢


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

void gnutls_transport_set_pull_timeout_function(gnutls_session_t
     session, gnutls_pull_timeout_func func);

πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_session_t session β€” bestie, this is a gnutls_session_t type. that's it, that's the whole description. iconic minimalism fr.
  • gnutls_pull_timeout_func func β€” a callback function. the little guy you're handing over πŸ’…

🌸 DESCRIPTION 🌸

so this is the function where you set the function that lets gnutls know whether data are ready to be received. that's the whole job. it should wait for data for a given time frame measured in milliseconds.

the callback's report card is:

  • return 0 on timeout,
  • return a positive number if data can be received,
  • return -1 on error.

you'll need to override this function if select() is not suitable for the provided transport calls. no cap, that's the rule.

and just like with select(), if the timeout value is zero, the callback should return zero if no data are immediately available. the special value GNUTLS_INDEFINITE_TIMEOUT means the callback should wait indefinitely for data. forever. periodt.

gnutls_pull_timeout_func is of the form:

int (*gnutls_pull_timeout_func)(gnutls_transport_ptr_t, unsigned int ms);

this callback is necessary when gnutls_handshake_set_timeout() or gnutls_record_set_timeout() are set, under TLS1.3, and for enforcing the DTLS mode timeouts when in blocking mode. so like... it matters. a lot.

for compatibility with future GnuTLS versions, this callback must be set when a custom pull function is registered. yes, even if it feels extra. the future is watching πŸ‘‘

heads up: the callback will not be used when the session is in TLS mode with non-blocking sockets. that is, when GNUTLS_NONBLOCK is specified for a TLS session in gnutls_init(). so don't come for it when it doesn't fire, bestie, it was literally told to sit this one out πŸ™ˆ

oh and the helper function gnutls_system_recv_timeout() is provided to simplify writing callbacks. she's here to help, use her 🧚


⭐ SINCE ⭐

3.0 β€” vintage, but still slaying.


πŸ› REPORTING BUGS πŸ›

found a bug? report it to <bugs@gnutls.org>.

home page: https://www.gnutls.org


Copyright Β© 2001-2023 Free Software Foundation, Inc., and others.

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. (so yes, you can share it, just keep the receipts πŸ’–)


πŸ‘€ SEE ALSO πŸ‘€

The full documentation for gnutls is maintained as a Texinfo manual. If the /usr/share/doc/gnutls/ directory does not contain the HTML form, visit:

https://www.gnutls.org/manual/

okay that's the whole page, you ate that 🌈 this was the gnutls manual, version 3.8.13, and the gnutls_transport_set_pull_timeout_function page β€” go set that callback and slay πŸ’…βœ¨πŸ’œ

πŸ“¦ where this page comes from