SSL_POLL(3SSL)
โจ SSL_POLL(3SSL) โ OpenSSL โจ
okay bestie, this is the moment. We're looking at the SSL_POLL(3SSL) manual page from OpenSSL, and it's literally about SSL_poll and a whole squad of event constants โ plus SSL_POLL_FLAG_NO_HANDLE_EVENTS โ all here to help you determine or await readiness conditions for one or more pollable objects. No cap. ๐ฆ
๐ NAME ๐
This page covers:
SSL_pollSSL_POLL_EVENT_NONESSL_POLL_EVENT_FSSL_POLL_EVENT_ELSSL_POLL_EVENT_ECSSL_POLL_EVENT_ECDSSL_POLL_EVENT_ERSSL_POLL_EVENT_EWSSL_POLL_EVENT_RSSL_POLL_EVENT_WSSL_POLL_EVENT_ICSSL_POLL_EVENT_ISBSSL_POLL_EVENT_ISUSSL_POLL_EVENT_OSBSSL_POLL_EVENT_OSUSSL_POLL_EVENT_RWSSL_POLL_EVENT_RESSL_POLL_EVENT_WESSL_POLL_EVENT_RWESSL_POLL_EVENT_ESSL_POLL_EVENT_ISSSL_POLL_EVENT_ISESSL_POLL_EVENT_ISSL_POLL_EVENT_OSSSL_POLL_EVENT_OSESSL_POLL_FLAG_NO_HANDLE_EVENTS
All of these are here to determine or await readiness conditions for one or more pollable objects. Periodt. ๐
๐ SYNOPSIS ๐
#include <openssl/ssl.h>
#define SSL_POLL_EVENT_NONE 0
#define SSL_POLL_EVENT_F /* F (Failure) */
#define SSL_POLL_EVENT_EL /* EL (Exception on Listener) */
#define SSL_POLL_EVENT_EC /* EC (Exception on Conn) */
#define SSL_POLL_EVENT_ECD /* ECD (Exception on Conn Drained) */
#define SSL_POLL_EVENT_ER /* ER (Exception on Read) */
#define SSL_POLL_EVENT_EW /* EW (Exception on Write) */
#define SSL_POLL_EVENT_R /* R (Readable) */
#define SSL_POLL_EVENT_W /* W (Writable) */
#define SSL_POLL_EVENT_IC /* IC (Incoming Connection) */
#define SSL_POLL_EVENT_ISB /* ISB (Incoming Stream: Bidi) */
#define SSL_POLL_EVENT_ISU /* ISU (Incoming Stream: Uni) */
#define SSL_POLL_EVENT_OSB /* OSB (Outgoing Stream: Bidi) */
#define SSL_POLL_EVENT_OSU /* OSU (Outgoing Stream: Uni) */
#define SSL_POLL_EVENT_RW /* R | W */
#define SSL_POLL_EVENT_RE /* R | ER */
#define SSL_POLL_EVENT_WE /* W | EW */
#define SSL_POLL_EVENT_RWE /* RE | WE */
#define SSL_POLL_EVENT_E /* EL | EC | ER | EW */
#define SSL_POLL_EVENT_IS /* ISB | ISU */
#define SSL_POLL_EVENT_ISE /* IS | EC */
#define SSL_POLL_EVENT_I /* IS */
#define SSL_POLL_EVENT_OS /* OSB | OSU */
#define SSL_POLL_EVENT_OSE /* OS | EC */
typedef struct ssl_poll_item_st {
BIO_POLL_DESCRIPTOR desc;
uint64_t events, revents;
} SSL_POLL_ITEM;
#define SSL_POLL_FLAG_NO_HANDLE_EVENTS
int SSL_poll(SSL_POLL_ITEM *items,
size_t num_items,
size_t stride,
const struct timeval *timeout,
uint64_t flags,
size_t *result_count);
๐ DESCRIPTION ๐
okay so SSL_poll() is the icon here. It lets the readiness conditions of the resources represented by one or more BIO_POLL_DESCRIPTOR structures be determined. In particular, it can be used to query for readiness conditions on QUIC connection SSL objects and QUIC stream SSL objects in a single call. It can also be used to block until at least one of the given resources is ready. Obsessed. ๐
A call to SSL_poll() specifies an array of SSL_POLL_ITEM structures, each of which designates a resource which is being polled for readiness, and a set of event flags which indicate the specific readiness events which the caller is interested in relation to the specified resource.
The fields of SSL_POLL_ITEM are literally everything, so let's go:
โจ desc โจ
The resource being polled for readiness, as represented by a BIO_POLL_DESCRIPTOR. Currently, this must be a poll descriptor of type BIO_POLL_DESCRIPTOR_TYPE_SSL, representing an SSL object pointer, and the SSL object must be a QUIC connection SSL object or QUIC stream SSL object.
If a SSL_POLL_ITEM has a poll descriptor type of BIO_POLL_DESCRIPTOR_TYPE_NONE, or the SSL object pointer is NULL, the SSL_POLL_ITEM array entry is ignored and revents will be set to 0 on return. Not me being invisible bestie, it's on purpose. ๐
๐ซ events ๐ซ
This is the set of zero or more events which the caller is interested in learning about in relation to the resource described by desc. It is a collection of zero or more SSL_POLL_EVENT flags. See "EVENT TYPES" for a description of each of the event types.
๐ฆ revents ๐ฆ
After SSL_poll() returns, this is the set of zero or more events which are actually applicable to the resource described by desc. As for events, it is a collection of zero or more SSL_POLL_EVENT flags.
revents need not be a subset of the events specified in events, as some event types are defined as always being enabled (non-maskable). See "EVENT TYPES" for more information. So yes, it can surprise you with extra slay. โจ
To use SSL_poll(), call it with an array of SSL_POLL_ITEM structures. The array need remain allocated only for the duration of the call. num_items must be set to the number of entries in the array, and stride must be set to sizeof(SSL_POLL_ITEM).
The timeout argument specifies the timeout to use, and, implicitly, whether to use SSL_poll() in blocking or nonblocking mode:
- If
timeoutisNULL, the function blocks indefinitely until at least one resource is ready. - If
timeoutis non-NULL, and it points to astruct timevalwhich is set to zero, the function operates in nonblocking mode and returns immediately with readiness information. - If
timeoutis non-NULL, and it points to astruct timevalwhich is set to a value other than zero, the function blocks for the specified interval or until at least one of the specified resources is ready, whichever comes first.
The present implementation of SSL_poll() is a subset of the functionality which will eventually be available. For more information, see "LIMITATIONS".
The following flags are currently defined for the flags argument:
๐ SSL_POLL_FLAG_NO_HANDLE_EVENTS ๐
This flag indicates that internal state machine processing should not be performed in an attempt to generate new readiness events. Only existing readiness events will be reported.
If this flag is used in nonblocking mode (with a timeout of zero), no internal state machine processing is performed.
If this flag is used in blocking mode (for example, with timeout set to NULL), event processing does not occur unless the function blocks.
The result_count argument is optional. If it is non-NULL, it is used to output the number of entries in the array which have nonzero revents fields when the call to SSL_poll() returns; see "RETURN VALUES" for details.
๐ EVENT TYPES ๐
okay so SSL_poll() can report zero or more event types on a given resource, and they come at you as a bit mask. ๐
All of these event types are level triggered and represent a readiness or permanent exception condition. That means once SSL_poll() reports one for a resource, it's gonna keep reporting it in future SSL_poll() calls until that condition stops being a thing. If you don't want the repeat notifications and you haven't caused the underlying readiness condition to be deasserted (like consuming all available data with SSL_read_ex(3) after SSL_POLL_EVENT_R shows up), you have to mask the event type bit in future SSL_poll() calls yourself. no cap.
Some event types just don't make sense on a certain kind of resource. In that case, putting that event type in events is a no-op, it gets ignored, and that event will never show up in revents. periodt.
Failure of the polling mechanism itself is distinct from an exception condition on a resource that was successfully polled. See SSL_POLL_EVENT_F and "RETURN VALUES" for the details. โจ
Generally, an application should always listen for the event types corresponding to exception conditions if it is listening to the corresponding non-exception event types (e.g. SSL_POLL_EVENT_EC and SSL_POLL_EVENT_ER for SSL_POLL_EVENT_R), because not doing so is unlikely to be a sound design. ๐ซถ
Some event types are non-maskable and may be reported in revents regardless of whether they were requested in events.
The following event types are supported:
SSL_POLL_EVENT_Fโ Polling failure. This one gets raised when a resource could not be polled. It is distinct from an exception condition reported on a resource which was successfully polled, and it represents a failure of the polling process itself in relation to a resource. This may mean thatSSL_poll()does not support the kind of resource specified. Where this event is raised on at least one item initems,SSL_poll()will return0and the ERR stack will contain information pertaining to the first item initemswithSSL_POLL_EVENT_Fset. See "RETURN VALUES" for more information. This event type may be raised even if it was not requested inevents; specifying this event type ineventsdoes nothing.SSL_POLL_EVENT_ELโ Error at listener level. This event is raised when a listener has failed, for example if a network BIO has encountered a permanent error. This event is never raised on objects which are not listeners, but its occurrence will causeSSL_POLL_EVENT_ECto be raised on all dependent connections.SSL_POLL_EVENT_ECโ Error at connection level. This event is raised when a connection has failed. In particular, it is raised when a connection begins terminating. This event is never raised on objects which are not connections.SSL_POLL_EVENT_ECDโ Error at connection level (drained). This event is raised when a connection has finished terminating, and has reached the terminated state. This event will generally occur after an interval of time passes after theSSL_POLL_EVENT_ECevent is raised on a connection. This event is never raised on objects which are not connections.SSL_POLL_EVENT_ERโ Error in read direction. For QUIC, this is raised only in the event that a stream has a read part and that read part has been reset by the peer (for example, using aRESET_STREAMframe).SSL_POLL_EVENT_EWโ Error in write direction. For QUIC, this is raised only in the event that a stream has a write part and that write part has been reset by the peer using aSTOP_SENDINGframe.SSL_POLL_EVENT_Rโ Readable. This event is raised when a QUIC stream SSL object (or a QUIC connection SSL object with a default stream attached) has application data waiting to be read usingSSL_read_ex(3), or a FIN event as represented bySSL_ERROR_ZERO_RETURNwaiting to be read. It is not raised in the event of the receiving part of the QUIC stream being reset by the peer; seeSSL_POLL_EVENT_ER.SSL_POLL_EVENT_Wโ Writable. This event is raised when a QUIC stream SSL object (or a QUIC connection SSL object with a default stream attached) could accept more application data usingSSL_write_ex(3). This event is never raised by a receive-only stream. This event is never raised by a stream which has had its send part concluded normally (as withSSL_stream_conclude(3)) or locally reset (as withSSL_stream_reset(3)). This event does not guarantee that a subsequent call toSSL_write_ex(3)will succeed.SSL_POLL_EVENT_ICโ This event, which is only raised by a QUIC listener SSL object, is raised when one or more incoming QUIC connections are available to be accepted usingSSL_accept_connection(3).SSL_POLL_EVENT_ISBโ This event, which is only raised by a QUIC connection SSL object, is raised when one or more incoming bidirectional streams are available to be accepted usingSSL_accept_stream(3).SSL_POLL_EVENT_ISUโ This event, which is only raised by a QUIC connection SSL object, is raised when one or more incoming unidirectional streams are available to be accepted usingSSL_accept_stream(3).SSL_POLL_EVENT_OSBโ This event, which is only raised by a QUIC connection SSL object, is raised when QUIC stream creation flow control currently permits at least one additional bidirectional stream to be locally created.SSL_POLL_EVENT_OSUโ This event, which is only raised by a QUIC connection SSL object, is raised when QUIC stream creation flow control currently permits at least one additional unidirectional stream to be locally created.
๐ง LIMITATIONS ๐ง
SSL_poll() as presently implemented has the following limitation:
- Only
BIO_POLL_DESCRIPTORstructures with typeBIO_POLL_DESCRIPTOR_TYPE_SSL, referencing QUIC listener, connection or stream SSL objects, are supported.
This limitation may be revised in a future release of OpenSSL. ๐ฎ
๐งต THREAD CANCELLATION ๐งต
A finite timeout limits ordinary waiting by SSL_poll(), but it does not make the call safe against thread cancellation; see openssl-threads(7). ๐ญ
Cancellation can prevent SSL_poll() from removing internal wait state. Because an items array can span multiple QUIC domains, one interrupted call can leave stale state in several domains and cause later calls on those domains, including SSL_poll() with a finite timeout, to block indefinitely. ๐
For cooperative cancellation, use a finite timeout and check a cancellation condition between calls; see "THREAD CANCELLATION" in openssl-quic-concurrency(7) for the nonblocking alternative.
๐ค RETURN VALUES ๐ค
SSL_poll() returns 1 on success and 0 on failure.
Unless the items pointer itself is invalid, SSL_poll() will always initialise the revents fields of all items in the input array upon returning, even if it returns failure.
If result_count is non-NULL, it is always written with the number of items in the array with nonzero revents fields, even if the SSL_poll() call returns failure.
It is possible for result_count to be written as 0 even if the SSL_poll() call returns success, namely if no events were output but the polling process was successful (e.g. in nonblocking usage) or timed out.
It is possible for result_count to be written as a nonzero value if the SSL_poll() call returns failure, for example due to SSL_POLL_EVENT_F events, or because some events were detected and output before encountering a failure condition while processing a subsequent entry in the items array.
If at least one SSL_POLL_EVENT_F event is output, SSL_poll() is guaranteed to return 0 and guaranteed to place at least one ERR on the error stack describing the first SSL_POLL_EVENT_F output. Detailed information on any additional SSL_POLL_EVENT_F events is not available. SSL_poll() may or may not return more than one SSL_POLL_EVENT_F event at once.
"Normal" events representing exceptional I/O conditions which do not constitute a failure of the SSL_poll() mechanism itself are not considered errors by SSL_poll() and are instead represented using their own event type; see "EVENT TYPES" for details. ๐
The caller can establish the meaning of the SSL_poll() return and output values as follows:
- If
SSL_poll()returns1andresult_countis zero, the operation timed out before any resource was ready. - If
SSL_poll()returns1andresult_countis nonzero, that many events were output. - If
SSL_poll()returns0andresult_countis zero, the caller has made a basic usage error; check the ERR stack for details. - If
SSL_poll()returns0andresult_countis nonzero, inspect theitemsarray forSSL_POLL_ITEMstructures with theSSL_POLL_EVENT_Fevent type raised inrevents. The entries added to the ERR stack (of which there is guaranteed to be at least one) reflect the cause of the failure of the first item initemswithSSL_POLL_EVENT_Fraised. Note that there may be events other thanSSL_POLL_EVENT_Foutput for items which come before the first item withSSL_POLL_EVENT_Fraised, and additionalSSL_POLL_EVENT_Fevents may or may not have been output, both of which will be reflected inresult_count.
๐ SEE ALSO ๐
BIO_get_rpoll_descriptor(3)BIO_get_wpoll_descriptor(3)SSL_get_rpoll_descriptor(3)SSL_get_wpoll_descriptor(3)openssl-threads(7)openssl-quic(7)openssl-quic-concurrency(7)
๐ HISTORY ๐
SSL_poll() was added in OpenSSL 3.3. ๐
Before 3.5, SSL_poll() did not support blocking operation and would fail if called with a NULL timeout parameter or a timeout parameter pointing to a struct timeval which was not zero.
Before 3.5, the SSL_POLL_EVENT_EL and SSL_POLL_EVENT_IC event types were not present.
ยฉ๏ธ COPYRIGHT ยฉ๏ธ
Copyright 2024-2026 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>.
and that's the whole page bestie ๐ this was OpenSSL 4.0.3, dated 2026-09-29, aka SSL_POLL(3SSL) โ go poll responsibly, ily โจ๐ฆ
๐ฆ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms