SSL_GET_ALL_ASYNC_FDS(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… SSL_GET_ALL_ASYNC_FDS πŸ’…

okay so bestie, this is a page from the OpenSSL manual (the 3ossl fam) and it's all about the three little functions that help you manage asynchronous operations β€” SSL_waiting_for_async, SSL_get_all_async_fds, and SSL_get_changed_async_fds. yes they all live in one page, they're a package deal, iykyk πŸŽ€


✨ SYNOPSIS ✨

like, literally just include these and you're so set:

#include <openssl/async.h>
#include <openssl/ssl.h>

int SSL_waiting_for_async(SSL *s);
int SSL_get_all_async_fds(SSL *s, OSSL_ASYNC_FD *fd, size_t *numfds);
int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd, size_t *numaddfds,
                              OSSL_ASYNC_FD *delfd, size_t *numdelfds);

🌸 DESCRIPTION 🌸

SSL_waiting_for_async()

she's the vibe check πŸ’… β€” she tells you whether an SSL connection is currently waiting for asynchronous operations to complete. (peep the SSL_MODE_ASYNC mode over in SSL_CTX_set_mode(3), that's the mood she's referencing πŸ¦‹)

SSL_get_all_async_fds()

okay so this one returns a list of file descriptors that you can hand to select() or poll() to figure out whether the current asynchronous operation has completed or not. and here's the iconic part: when it's done, data shows up as "read ready" on the file descriptor β€” but bestie, do not actually read any data from that fd, it's just the signal, not a snack πŸ™ˆ

🚨 vibe check: only call this if the SSL object is currently waiting for async work to finish β€” meaning you got SSL_ERROR_WANT_ASYNC back (see SSL_get_error(3)). don't be out here calling her when she's not waiting, it's not that kind of party.

typically the list has just one file descriptor in it. but lowkey if multiple async-capable engines are in use, more than one is possible β€” main character energy, the more the merrier πŸ‘‘

how it works: the number of fds returned gets stored in *numfds, and the fds themselves go in *fds. the fds parameter may be NULL, in which case no fds are returned but *numfds still gets populated (she's still gonna tell you the count, no cap). and it is the caller's responsibility to make sure there's enough memory allocated at *fds β€” which is why this function is typically called twice: once with a NULL fds parameter, and once without. two-step slay ✨

SSL_get_changed_async_fds()

this one returns two lists, iconic behavior honestly: the async file descriptors that have been added, and the ones that have been deleted since the last SSL_ERROR_WANT_ASYNC was received (or, if you never got one, since the SSL object was created πŸŽ€).

same deal as SSL_get_all_async_fds(): it is the caller's responsibility to ensure *addfd and *delfd have sufficient memory allocated β€” although, yeah, they may be NULL. the number of added fds goes in *numaddfds, and the number of deleted fds goes in *numdelfds, respectively. πŸ’–


πŸ¦‹ RETURN VALUES πŸ¦‹

  • SSL_waiting_for_async() returns 1 if the current SSL operation is waiting for an async operation to complete, and 0 otherwise. that's it, that's the whole mood.
  • SSL_get_all_async_fds() and SSL_get_changed_async_fds() return 1 on success or 0 on error. simple, clean, periodt.

πŸ’€ NOTES πŸ’€

Windows girlies listen up 😭 β€” on Windows platforms, the <openssl/async.h> header is dependent on some of the types customarily made available by including <windows.h>. and the application developer is likely going to want control over when <windows.h> gets included, commonly as one of the first included headers. so, fr fr, it's defined as an application developer's responsibility to include <windows.h> prior to <openssl/async.h>. order matters bestie, don't get it twisted 🫢


🌈 SEE ALSO 🌈

ssl(7), SSL_get_error(3), SSL_CTX_set_mode(3) β€” go read those too, they're all in the group chat πŸ’œ


πŸ‘‘ HISTORY πŸ‘‘

the SSL_waiting_for_async(), SSL_get_all_async_fds() and SSL_get_changed_async_fds() functions were added in OpenSSL 1.1.0. glow-up since day one ⭐


Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


that's the whole page bb πŸ’– this was version 3.5.6, dated 2026-04-07, and it's the SSL_GET_ALL_ASYNC_FDS(3ossl) page β€” go forth and async responsibly, mwah 🧚✨

πŸ“¦ where this page comes from