gnutls_record_send_file(3)

πŸ’– gnutls_record_send_file(3) πŸ’–

okay so bestie, welcome to the gnutls manual, and today's episode is all about gnutls_record_send_file β€” an API function that yeets a whole file down your TLS connection. no cap, this one is lowkey iconic. πŸ¦‹


✨ NAME ✨

gnutls_record_send_file β€” API function, aka "the file-sending one". πŸ’…


🌸 SYNOPSIS 🌸

#include <gnutls/gnutls.h>

ssize_t gnutls_record_send_file(gnutls_session_t session, int fd, off_t
* offset, size_t count);

πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_session_t session β€” bestie this is just a gnutls_session_t type. the session, the vibe, the whole thing. πŸ’œ
  • int fd β€” the file descriptor you're gonna read data from. your source. your supply. πŸ“‚
  • off_t * offset β€” it's relative to the file offset, and it marks the starting location for reading. after the function returns, it points to the position following the last read byte. (not me checking exactly where we landed πŸ™ˆ)
  • size_t count β€” the length of the data, in bytes, to be read from the file and sent. that's your byte budget fr fr. πŸ”’

πŸ¦‹ DESCRIPTION πŸ¦‹

so this function sends data from fd. and here's the tea: if KTLS (kernel TLS) is enabled, it will use the sendfile() system call to avoid the overhead of copying data between user space and the kernel. slay, zero-copy, main character energy. ✨

otherwise? this functionality is merely emulated by calling read() and gnutls_record_send(). it's giving "we got sendfile at home". 😭

if this implementation is suboptimal, check whether KTLS is enabled using gnutls_transport_is_ktls_enabled(). that's your vibe check, go do it. πŸ‘‘

also, important: if offset is NULL then the file offset is incremented by the number of bytes send, otherwise the file offset remains unchanged. (yes it says "send" in the original, and yes we're keeping it exactly, periodt πŸ’…)


⭐ RETURNS ⭐

the number of bytes sent, or a negative error code. that's it, that's the return. 🌈


πŸ’€ REPORTING BUGS πŸ’€

found a bug? not cute. 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.


🫢 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 manual shipped as part of gnutls 3.8.13 β€” go forth and send those files, iykyk. mwah πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from