Lines Matching +full:continue +full:- +full:on +full:- +full:error
6 demos/guide/tls-client-non-block.c
12 ossl-guide-tls-client-non-block
13 - OpenSSL Guide: Writing a simple nonblocking TLS client
17 This page will build on the example developed on the
18 L<ossl-guide-tls-client-block(7)> page which demonstrates how to write a simple
19 blocking TLS client. On this page we will amend that demo code so that it
24 B<tls-client-non-block.c>. It is also available online at
25 L<https://github.com/openssl/openssl/blob/master/demos/guide/tls-client-non-block.c>.
32 will simply stop until it is able to continue. However in many cases you do not
35 updating a GUI or performing operations on some other socket.
38 currently unable to read or write will return immediately with a non-fatal
39 error. Although OpenSSL does the reading/writing to the socket this nonblocking
43 Since this page is building on the example developed on the
44 L<ossl-guide-tls-client-block(7)> page we assume that you are familiar with it
51 exact details on how to do this can differ from one platform to another.
56 sock = -1;
57 continue;
61 call whatever functions that your Operating System provides for this purpose on
111 * Let's say for example that you want to update the progress counter on
114 * you check if it did so because of activity on the file descriptors or
125 to use and is available on most Operating Systems. However you could use any
138 connection has failed), or non-fatal (for example because we are trying to read
141 L<SSL_read_ex(3)> and L<SSL_write_ex(3)> will return 0 to indicate an error and
143 an error. L<SSL_shutdown(3)> will return a negative value to incidate an error.
145 In the event of an error an application should call L<SSL_get_error(3)> to find
146 out what type of error has occurred. If the error is non-fatal and can be
148 B<SSL_ERROR_WANT_WRITE> depending on whether OpenSSL wanted to read to or write
155 Another type of non-fatal error that may occur is B<SSL_ERROR_ZERO_RETURN>. This
156 indicates an EOF (End-Of-File) which can occur if you attempt to read data from
158 on it. In this case you may still want to write data to the connection but you
165 further details. B<SSL_ERROR_SSL> indicates that some OpenSSL error occurred. You
166 can consult the OpenSSL error stack for further details (for example by calling
190 return -1;
194 * If the failure is due to a verification error we can get more
198 printf("Verify error: %s\n",
200 return -1;
203 return -1;
209 the event of a non-fatal failure, it waits until a retry of the I/O operation
211 in the previous section). It returns 1 in the event of a non-fatal error
212 (except EOF), 0 in the event of EOF, or -1 if a fatal error occurred.
218 on the L<ossl-guide-tls-client-block(7)> page. We won't repeat that information
225 socket it is very likely that calls to this function will fail with a non-fatal
226 error while we are waiting for the server to respond to our handshake messages.
233 continue; /* Retry */
235 goto end; /* Cannot retry: error */
241 this stage, so such a response is treated in the same way as a fatal error.
247 a nonblocking socket, this call could fail with a non-fatal error. In that case
250 write with the same length. You must not attempt to send different data on a
254 same data - even though the buffer that contains that data may change location.
256 blocking tutorial (L<ossl-guide-tls-client-block(7)>) we write the request
262 continue; /* Retry */
264 goto end; /* Cannot retry: error */
268 continue; /* Retry */
270 goto end; /* Cannot retry: error */
274 continue; /* Retry */
276 goto end; /* Cannot retry: error */
279 On a write we do not expect to see an EOF response so we treat that case in the
280 same way as a fatal error.
292 continue; /* Retry */
295 continue;
296 case -1:
299 goto end; /* Cannot retry: error */
305 * number of bytes that we read. The data could be non-printable or
320 from the server. We continue going around the loop until we either encounter a
321 fatal error, or we receive an EOF (indicating a graceful finish).
329 L<SSL_shutdown(3)> give a return value of 0, and then we would continue to call
345 continue; /* Retry */
352 printf("Error shutting down\n");
353 goto end; /* Cannot retry: error */
364 See L<ossl-guide-tls-client-block(7)> to read a tutorial on how to write a
365 blocking TLS client. See L<ossl-guide-quic-client-block(7)> to see how to do the
370 L<ossl-guide-introduction(7)>, L<ossl-guide-libraries-introduction(7)>,
371 L<ossl-guide-libssl-introduction(7)>, L<ossl-guide-tls-introduction(7)>,
372 L<ossl-guide-tls-client-block(7)>, L<ossl-guide-quic-client-block(7)>