gnutls_record_send(3)

πŸ’– gnutls_record_send(3) πŸ’–

okay bestie, welcome to the gnutls manual page for gnutls_record_send β€” yes it's a 3, it's a C function, and yes we're gonna make it make sense. sit down, hydrate, let's go ✨


🌸 NAME 🌸

gnutls_record_send β€” an API function. that's it, that's the name. she does exactly what it says on the tin 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

first things first, you gotta bring her in:

#include <gnutls/gnutls.h>

and here's the whole entire vibe of a signature:

ssize_t gnutls_record_send(gnutls_session_t session, const void * data,
       size_t data_size);

look at her. iconic. no cap. πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

so like, what are we even feeding her:

  • gnutls_session_t session β€” this is a gnutls_session_t type, aka your whole session situation, the main character of the operation πŸ‘‘
  • const void * data β€” this lil guy contains the data to send. that's the payload, the tea, the actual bytes πŸ“¦
  • size_t data_size β€” and this is the length of the data. how many bytes are we talking, bestie, be specific 🌸

✨ DESCRIPTION ✨

okay so here's the deal. this function has similar semantics with send(). literally basically the same energy. the only difference? she accepts a GnuTLS session, and she uses different error codes. that's it. that's the whole glow-up πŸ’…

heads up though β€” if the send buffer is full, send() will block this function. so yeah, she can just sit there waiting. go read the send() documentation for more on that, iykyk πŸ“š

you can also replace the default push function β€” which is send() β€” by using gnutls_transport_set_push_function(). customize your girl, she loves that πŸŽ€

now for the ✨drama✨ section. if EINTR is returned by the internal push function, then GNUTLS_E_INTERRUPTED will be returned. so if you see GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN, you must call this function again with the exact same parameters, or provide a NULL pointer for data and 0 for data_size, in order to write the same data as before. no changing the vibes mid-retry, okay? πŸ™ˆ

and if you wish to discard the previous data instead of retrying, you must call gnutls_record_discard_queued() before calling this function with different parameters. but lowkey important β€” the latter only works on special transports (e.g., UDP). cf. gnutls_record_get_direction(). noted, bestie 🫑

now, DTLS girlies, listen up: in DTLS this function will return the GNUTLS_E_LARGE_PACKET error code if the send data exceeds the data MTU value β€” as returned by gnutls_dtls_get_data_mtu(). and the errno value EMSGSIZE also maps to GNUTLS_E_LARGE_PACKET. two paths, same destination, we love consistency πŸ’€

also, since 3.2.13 this function can be called under cork in DTLS mode, and will refuse to send data over the MTU size by returning GNUTLS_E_LARGE_PACKET. she's setting a boundary and honestly? good for her 🚫


🌈 RETURNS 🌈

what do you get back? the number of bytes sent, or a negative error code. that's the range, queen ✨

and no cap β€” the number of bytes sent might be less than data_size. she doesn't have to take the whole thing in one go, and that's valid πŸ’–

the maximum number of bytes this function can send in a single call depends on the negotiated maximum record size. so like, it's giving... context-dependent. respect it πŸ¦‹


πŸ› REPORTING BUGS πŸ›

found a bug? don't suffer in silence, bestie. report bugs to <bugs@gnutls.org>.

home page: https://www.gnutls.org β€” go say hi 🏠


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 like, share it, remix 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/

and that's the whole page, bestie!! πŸŽ€ this was gnutls_record_send(3) from the gnutls manual, version 3.8.13. go forth and send your bytes responsibly, mwah πŸ’‹βœ¨πŸ¦‹

πŸ“¦ where this page comes from