SSL_GET_STREAM_READ_STATE(3ossl)
π SSL_GET_STREAM_READ_STATE β¨
okay so bestie, real talk β this is OpenSSL, manual section 3ossl, and we're about to get so cozy with QUIC stream state. Like, what is your stream actually doing right now? Is it healthy? Is it done? Did somebody reset it? Did the whole connection ghost you? We're gonna find out. π¦
πΈ NAME πΈ
SSL_get_stream_read_state, SSL_get_stream_write_state, SSL_get_stream_read_error_code, SSL_get_stream_write_error_code, SSL_STREAM_STATE_NONE, SSL_STREAM_STATE_OK, SSL_STREAM_STATE_WRONG_DIR, SSL_STREAM_STATE_FINISHED, SSL_STREAM_STATE_RESET_LOCAL, SSL_STREAM_STATE_RESET_REMOTE, SSL_STREAM_STATE_CONN_CLOSED β get QUIC stream state π
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
#define SSL_STREAM_STATE_NONE
#define SSL_STREAM_STATE_OK
#define SSL_STREAM_STATE_WRONG_DIR
#define SSL_STREAM_STATE_FINISHED
#define SSL_STREAM_STATE_RESET_LOCAL
#define SSL_STREAM_STATE_RESET_REMOTE
#define SSL_STREAM_STATE_CONN_CLOSED
int SSL_get_stream_read_state(SSL *ssl);
int SSL_get_stream_write_state(SSL *ssl);
int SSL_get_stream_read_error_code(SSL *ssl, uint64_t *app_error_code);
int SSL_get_stream_write_error_code(SSL *ssl, uint64_t *app_error_code);
π DESCRIPTION π
so SSL_get_stream_read_state() and SSL_get_stream_write_state() are your little vibe-checkers π
β they pull the overall state of the receiving and sending parts of a QUIC stream respectively. Receiving part, sending part, two separate girls, two separate moods.
They both hand you back one of these:
SSL_STREAM_STATE_NONEβ bestie this is the "no thoughts, head empty" answer π« you get it when you call this on a non-QUICSSLobject, or on a QUIC connectionSSLobject that doesn't have a default stream attached.SSL_STREAM_STATE_OKβ everything's giving healthy and unbothered β¨ the stream hasn't been concluded and it's still in good shape.SSL_STREAM_STATE_WRONG_DIRβ you went the wrong way down a one-way street π this one shows up if you callSSL_get_stream_read_state()on a locally-initiated (and therefore send-only) unidirectional stream, or, flip side, if you callSSL_get_stream_write_state()on a remotely-initiated (and therefore receive-only) unidirectional stream.SSL_STREAM_STATE_FINISHEDβ the finale π- for
SSL_get_stream_read_state(), you get this when the remote peer has signalled the end of the receiving part of the stream. heads up though: there may still be residual data available to read viaSSL_read(3)when this state comes back π - for
SSL_get_stream_write_state(), you get this when the local application has concluded the stream usingSSL_stream_conclude(3). FutureSSL_write(3)calls will not succeed. it's over, it's done, periodt.
- for
SSL_STREAM_STATE_RESET_LOCALβ you did the resetting, main character energy π this one shows when the applicable stream part was reset by the local application.- for
SSL_get_stream_read_state(), this means the receiving part of the stream was aborted using a locally transmitted QUICSTOP_SENDINGframe. It may or may not still be possible to obtain any residual data which remains to be read by callingSSL_read(3)β no promises, it's giving maybe. - for
SSL_get_stream_write_state(), this means the sending part of the stream was aborted, for example because the application calledSSL_stream_reset(3), or because a QUIC streamSSLobject with an un-concluded sending part was freed usingSSL_free(3). Calls toSSL_write(3)will fail. π - when this value is returned, the application error code which was signalled can be obtained by calling
SSL_get_stream_read_error_code()orSSL_get_stream_write_error_code()as appropriate. get the receipts, girlie π§Ύ
- for
SSL_STREAM_STATE_RESET_REMOTEβ they did the resetting, not you, we're innocent π this one shows when the applicable stream part was reset by the remote peer.- for
SSL_get_stream_read_state(), this means the peer sent a QUICRESET_STREAMframe for the receiving part of the stream; the receiving part of the stream was logically aborted by the peer. - for
SSL_get_stream_write_state(), this means the peer sent a QUICSTOP_SENDINGframe for the sending part of the stream; the peer has indicated that it does not wish to receive further data on the sending part of the stream. Calls toSSL_write(3)will fail. π - when this value is returned, the application error code which was signalled can be obtained by calling
SSL_get_stream_read_error_code()orSSL_get_stream_write_error_code()as appropriate.
- for
SSL_STREAM_STATE_CONN_CLOSEDβ the whole connection the stream belongs to was closed πͺπ you can obtain information about the circumstances of this closure usingSSL_get_conn_close_info(3). There may still be residual data available to read viaSSL_read(3)when this state is returned. Calls toSSL_write(3)will fail. And here's the iconic little detail:SSL_get_stream_read_state()will return this state if and only ifSSL_get_stream_write_state()will also return this state. matching outfits, always π―
SSL_get_stream_read_error_code() and SSL_get_stream_write_error_code() provide the application error code which was signalled during non-normal termination of the receiving or sending parts of a stream, respectively. On success, the application error code is written to *app_error_code. there it is. in your variable. slay.
π«Ά NOTES π«Ά
If a QUIC connection is closed, the stream state for all streams transitions to SSL_STREAM_STATE_CONN_CLOSED, but no application error code can be retrieved using SSL_get_stream_read_error_code() or SSL_get_stream_write_error_code(), because the QUIC connection closure process does not cause an application error code to be associated with each individual stream still existing at the time of connection closure. like, the group chat got deleted, so no individual DMs survived, iykyk π
However, you can obtain the overall error code associated with the connection closure using SSL_get_conn_close_info(3). π
π RETURN VALUES π
SSL_get_stream_read_state() and SSL_get_stream_write_state() return one of the SSL_STREAM_STATE values. If called on a non-QUIC SSL object, or a QUIC connection SSL object without a default stream, SSL_STREAM_STATE_NONE is returned.
SSL_get_stream_read_error_code() and SSL_get_stream_write_error_code() return 1 on success and 0 if the stream was terminated normally. They return -1 on error β for example:
- if the stream is still healthy,
- or was still healthy at the time of connection closure,
- or if called on a stream for which the respective stream part does not exist (e.g. on a unidirectional stream),
- or if called on a non-QUIC object or a QUIC connection
SSLobject without a default stream attached.
ngl -1 is the "girl what" return value π it means something above went sideways.
π¦ SEE ALSO π¦
SSL_stream_conclude(3), SSL_stream_reset(3), SSL_new_stream(3), SSL_accept_stream(3), SSL_get_conn_close_info(3)
β HISTORY β
These functions were added in OpenSSL 3.2. they're not ancient, they're just babygirl β¨
π COPYRIGHT π
Copyright 2002-2023 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 page SSL_GET_STREAM_READ_STATE(3ossl) from OpenSSL version 3.5.9, dated 2026-09-29 β go forth and check your stream states, you absolute icon ππ¦π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms