Lines Matching +full:if +full:- +full:mode +full:- +full:en

1 .\" -*- mode: troff; coding: utf-8 -*-
33 .\" If the F register is >0, we'll generate index entries on stderr for
44 . if \nF \{\
48 . if !\nF==2 \{\
57 .IX Title "OSSL-GUIDE-QUIC-CLIENT-NON-BLOCK 7ossl"
58 .TH OSSL-GUIDE-QUIC-CLIENT-NON-BLOCK 7ossl 2025-09-30 3.5.4 OpenSSL
64 ossl\-guide\-quic\-client\-non\-block
65 \&\- OpenSSL Guide: Writing a simple nonblocking QUIC client
69 \&\fBossl\-guide\-quic\-client\-block\fR\|(7) page which demonstrates how to write a simple
75 \&\fBquic\-client\-non\-block.c\fR. It is also available online at
76 <https://github.com/openssl/openssl/blob/master/demos/guide/quic\-client\-non\-block.c>.
81 it waits (blocks) until data is available to read if you attempt to read from
82 it when there is no data yet. Similarly it waits when writing if the \fBSSL\fR
93 \&\fBSSL_read_ex\fR\|(3) or \fBSSL_write_ex\fR\|(3) will return immediately with a non-fatal
94 error if they are currently unable to read or write respectively.
97 \&\fBossl\-guide\-quic\-client\-block\fR\|(7) page we assume that you are familiar with it
106 operation that it previously attempted periodically to see if it can now
112 tried last time. You cannot start something new. For example if you were
138 \& * Find out if we would like to write to the socket, or read from it (or
141 \& if (SSL_net_write_desired(ssl))
143 \& if (SSL_net_read_desired(ssl))
151 \& if (SSL_get_event_timeout(ssl, &tv, &isinfinite) && !isinfinite)
166 \& * the last parameter to "select" below. If the tvp value is greater
168 \& * check if it did so because of activity on the file descriptors or
169 \& * because of the timeout. If the 100ms GUI timeout has expired but the
179 TLS (see \fBossl\-guide\-tls\-client\-non\-block\fR\|(7)) then you should note that there
181 application works. With a TLS application if we try to read or write something
203 that OpenSSL must be called again by is to use "thread assisted" mode. In
204 "thread assisted" mode OpenSSL spawns an additional thread which will
222 has failed), or non-fatal (for example because we are trying to read from the
230 out what type of error has occurred. If the error is non-fatal and can be
237 Another type of non-fatal error that may occur is \fBSSL_ERROR_ZERO_RETURN\fR. This
238 indicates an EOF (End-Of-File) which can occur if you attempt to read data from
273 \& return \-1;
278 \& * stream reset \- or some failure occurred on the underlying
283 \& printf("Stream reset occurred\en");
291 \& printf("Connection closed\en");
296 \& printf("Unknown stream failure\en");
300 \& * If the failure is due to a verification error we can get more
303 \& if (SSL_get_verify_result(ssl) != X509_V_OK)
304 \& printf("Verify error: %s\en",
306 \& return \-1;
309 \& return \-1;
316 the event of a non-fatal failure, it waits until a retry of the I/O operation
318 in the previous section). It returns 1 in the event of a non-fatal error
319 (except EOF), 0 in the event of EOF, or \-1 if a fatal error occurred.
324 explained on the \fBossl\-guide\-quic\-client\-block\fR\|(7) page. We won't repeat that
327 One key difference is that we must put the \fBSSL\fR object into nonblocking mode
328 (the default is blocking mode). To do that we use the
335 \& * mode in this demo.
337 \& if (!SSL_set_blocking_mode(ssl, 0)) {
338 \& printf("Failed to turn off blocking mode\en");
344 possible to use "thread assisted mode" when developing QUIC applications.
351 object idle for some time when using nonblocking mode. By using "thread assisted
352 mode" a separate thread is created by OpenSSL to do this automatically which
359 \& if (ctx == NULL) {
360 \& printf("Failed to create the SSL_CTX\en");
369 non-fatal error while we are waiting for the server to respond to our handshake
376 \& if (handle_io_failure(ssl, ret) == 1)
378 \& printf("Failed to connect to server\en");
391 a nonblocking \fBSSL\fR object, this call could fail with a non-fatal error. In
395 data on a retry. An optional mode does exist
398 case, you must still retry exactly the same data \- even though the buffer that
400 details. As in the TLS tutorials (\fBossl\-guide\-tls\-client\-block\fR\|(7)) we write
412 \& if (handle_io_failure(ssl, 0) == 1)
414 \& printf("Failed to write start of HTTP request\en");
418 \& if (handle_io_failure(ssl, 0) == 1)
420 \& printf("Failed to write hostname in HTTP request\en");
425 \& if (handle_io_failure(ssl, 0) == 1)
427 \& printf("Failed to write end of HTTP request\en");
450 \& case \-1:
452 \& printf("Failed reading remaining data\en");
459 \& * number of bytes that we read. The data could be non\-printable or
463 \& if (!eof)
467 \& printf("\en");
491 have to retry this operation several times. If \fBSSL_shutdown\fR\|(3) returns a
502 \& if (ret < 0 && handle_io_failure(ssl, ret) == 1)
513 See \fBossl\-guide\-quic\-client\-block\fR\|(7) to read a tutorial on how to write a
514 blocking QUIC client. See \fBossl\-guide\-quic\-multi\-stream\fR\|(7) to see how to write
515 a multi-stream QUIC client.
518 \&\fBossl\-guide\-introduction\fR\|(7), \fBossl\-guide\-libraries\-introduction\fR\|(7),
519 \&\fBossl\-guide\-libssl\-introduction\fR\|(7), \fBossl\-guide\-quic\-introduction\fR\|(7),
520 \&\fBossl\-guide\-quic\-client\-block\fR\|(7), \fBossl\-guide\-quic\-multi\-stream\fR\|(7)
523 Copyright 2023\-2025 The OpenSSL Project Authors. All Rights Reserved.