TLS_ACCEPT_SOCKET(3)

πŸ“¦ version 4.1.0, in opensuse-leap 16.0

πŸ’– tls_accept_socket β€” the manual page, bestie edition πŸ’–

okay so this is a page from the Library Functions Manual, and it's all about tls_accept_socket, tls_accept_fds and tls_accept_cbs. three little icons whose whole job is accepting an incoming client connection in a TLS server. yes queen, let's get into it 🫢


✨ NAME ✨

tls_accept_socket, tls_accept_fds, tls_accept_cbs β€” accept an incoming client connection in a TLS server πŸŽ€


✨ SYNOPSIS ✨

first things first, you gotta invite the header in:

#include <tls.h>

then, the three mains:

int
tls_accept_socket(struct tls *tls, struct tls **cctx, int socket);

int
tls_accept_fds(struct tls *tls, struct tls **cctx, int fd_read,
    int fd_write);

int
tls_accept_cbs(struct tls *tls, struct tls **cctx,
    ssize_t (*tls_read_cb)(struct tls *ctx, void *buf, size_t buflen, void *cb_arg),
    ssize_t (*tls_write_cb)(struct tls *ctx, const void *buf, size_t buflen, void *cb_arg),
    void *cb_arg);

no cap, those callback signatures are a mouthful, but we love them anyway πŸ’…


✨ DESCRIPTION ✨

so here's the tea. once you've made yourself a TLS server context called tls with tls_server(3) and you've configured it all cute with tls_configure(3), your server can accept a brand new client connection by calling tls_accept_socket() on a socket connection that's already established. she's ready, she's connected, she's serving πŸ”₯

alternatively β€” and this is the glow-up option β€” you can accept a new client connection over a pair of existing file descriptors by calling tls_accept_fds(). two fds, one dream πŸ¦‹

and then there's tls_accept_cbs(), which is giving main character energy because it lets read and write callback functions handle the data transfers. the cb_arg parameter you specify gets passed right back to those functions, and it can hold a pointer to literally any caller-specified data you want. it's your little passenger princess, riding along for the whole trip πŸ’œ

the important part: all of these functions create a new context that's suitable for reading and writing, and they hand it back to you in *cctx. slay.


✨ RETURN VALUES ✨

0 on success, -1 on error. that's it, that's the whole vibe check 🌸


✨ SEE ALSO ✨

go read these next, bestie, they're all connected:


✨ HISTORY ✨

a lil lore lesson for you πŸŽ€

  • tls_accept_socket() showed up in OpenBSD 5.6 and then got its final name in OpenBSD 5.7. glow-up era ✨
  • tls_accept_fds() appeared in OpenBSD 5.8, and tls_accept_cbs() arrived in OpenBSD 6.1. the squad just kept growing 😭

✨ AUTHORS ✨

  • Joel Sing <jsing@openbsd.org> πŸ‘‘
  • tls_accept_cbs() was written by Tobias Pape <tobias@netshed.de> 🫢

and that's the page!! this version of the manual ships with Debian, dated May 26, 2018 β€” so like, respectfully, it's a little vintage, but the info still eats πŸ’…πŸ’– bye bestie, go accept some connections 🌈

πŸ“¦ where this page comes from