TLS_ACCEPT_SOCKET(3)
π 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, andtls_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
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
- Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
- Copyright (c) 2016 Brent Cook <bcook@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms