diff options
Diffstat (limited to 'demos/guide/quic-client-block.c')
-rw-r--r-- | demos/guide/quic-client-block.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/demos/guide/quic-client-block.c b/demos/guide/quic-client-block.c index be797707f1..54e52d5c28 100644 --- a/demos/guide/quic-client-block.c +++ b/demos/guide/quic-client-block.c @@ -251,13 +251,37 @@ int main(void) * QUIC terms this means that the peer has sent FIN on the stream to * indicate that no further data will be sent. */ - if (SSL_get_error(ssl, 0) != SSL_ERROR_ZERO_RETURN) { + switch (SSL_get_error(ssl, 0)) { + case SSL_ERROR_ZERO_RETURN: + /* Normal completion of the stream */ + break; + + case SSL_ERROR_SSL: /* - * Some error occurred other than a graceful close down by the - * peer. + * Some stream fatal error occurred. This could be because of a stream + * reset - or some failure occurred on the underlying connection. */ + switch (SSL_get_stream_read_state(ssl)) { + case SSL_STREAM_STATE_RESET_REMOTE: + printf("Stream reset occurred\n"); + /* The stream has been reset but the connection is still healthy. */ + break; + + case SSL_STREAM_STATE_CONN_CLOSED: + printf("Connection closed\n"); + /* Connection is already closed. Skip SSL_shutdown() */ + goto end; + + default: + printf("Unknown stream failure\n"); + break; + } + break; + + default: + /* Some other unexpected error occurred */ printf ("Failed reading remaining data\n"); - goto end; + break; } /* |