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-SERVER-NON-BLOCK 7ossl"
58 .TH OSSL-GUIDE-QUIC-SERVER-NON-BLOCK 7ossl 2025-09-30 3.5.4 OpenSSL
64 ossl\-guide\-quic\-server\-non\-block
65 \&\- OpenSSL Guide: Writing a simple nonblocking QUIC server
69 simple, non-concurrent, QUIC "echo" server application which accepts one client
73 The server only accepts \f(CW\*(C`http/1.0\*(C'\fR and \f(CW\*(C`hq\-interop\*(C'\fR ALPN's and doe…
74 implement HTTP but only does a simple echo. This is non-standard and will not
77 There are various methods to test this server: \fBquic\-client\-block.c\fR and
78 \&\fBquic\-client\-non\-block.c\fR will send a basic HTTP/1.0 request, which the server
80 \&\f(CW\*(C`openssl s_client \-connect localhost:4443 \-4 \-quic \-alpn http/1.0\*(C'\fR and enteri…
91 \&\fBquic\-server\-non\-block.c\fR. It is also available online at
92 <https://github.com/openssl/openssl/blob/master/demos/guide/quic\-server\-non\-block.c>.
96 \&\fBossl\-guide\-libraries\-introduction\fR\|(7) and \fBossl\-guide\-quic\-introduction\fR\|(7));
110 \& * subsequent per\-client SSL connections. We specifically load a QUIC
114 \& if (ctx == NULL)
119 certificates are often required, and both the server (end-entity or EE)
131 \& * not only the leaf (end\-entity) server certificate, but also any
132 \& * intermediate issuer\-CA certificates. The leaf certificate must be the
135 \& * In advanced use\-cases this can be called multiple times, once per public
140 \& if (SSL_CTX_use_certificate_chain_file(ctx, cert_path) <= 0) {
141 \& fprintf(stderr, "couldn\*(Aqt load certificate file: %s\en", cert_path);
147 \& * key matches the just loaded end\-entity certificate. It does not check
152 \& if (SSL_CTX_use_PrivateKey_file(ctx, key_path, SSL_FILETYPE_PEM) <= 0) {
153 \& fprintf(stderr, "couldn\*(Aqt load key file: %s\en", key_path);
160 when the client does not present a certificate. Note: Even if a client did
177 \& * Clients rarely employ certificate\-based authentication, and so we don\*(Aqt
183 \& * need to configure a trusted\-certificate store, so no call to
190 QUIC also dictates using Application-Layer Protocol Negotiation (ALPN) to select
200 In this case, we only accept "http/1.0" and "hq-interop".
204 \& * ALPN strings for TLS handshake. Only \*(Aqhttp/1.0\*(Aq and \*(Aqhq\-interop\*(Aq
209 \& 10, \*(Aqh\*(Aq, \*(Aqq\*(Aq, \*(Aq\-\*(Aq, \*(Aqi\*(Aq, \*(Aqn\*(Aq, \*(Aqt\*(Aq, \*(Aqe…
216 \& if (SSL_select_next_proto((unsigned char **)out, out_len, alpn_ossltest,
229 \& if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
231 \& return \-1;
238 \& if (bind(fd, (const struct sockaddr *)&sa, sizeof(sa)) < 0) {
239 \& fprintf(stderr, "cannot bind to %u\en", port);
241 \& return \-1;
244 \& /* Set port to nonblocking mode */
245 \& if (BIO_socket_nbio(fd, 1) <= 0) {
246 \& fprintf(stderr, "Unable to set port to nonblocking mode");
248 \& return \-1;
258 \& if ((listener = SSL_new_listener(ctx, 0)) == NULL)
262 \& if (!SSL_set_fd(listener, fd))
265 \& /* Set the listener mode to nonblocking, which is inherited by
268 \& if (!SSL_set_blocking_mode(listener, 0))
273 \& * will implicitly start listening. It is only needed if a server wishes to
277 \& if (!SSL_listen(listener))
296 occurred. However, since we are in nonblocking mode, \fBSSL_accept_connection\fR\|(3)
301 \& printf("Waiting for connection\en");
305 \& printf("Accepted new connection\en");
310 a more real-world application would likely use this time to perform other tasks.
318 \& * Determine if we would like to write to the socket, read from it, or both.
320 \& if (SSL_net_write_desired(ssl))
322 \& if (SSL_net_read_desired(ssl))
329 \& if (SSL_get_event_timeout(ssl, &tv, &isinfinite) && !isinfinite)
344 \& * the last parameter to "select" below. If the tvp value is greater
346 \& * check if it did so because of activity on the file descriptors or
347 \& * because of the timeout. If the 100ms GUI timeout has expired but the
360 \& ret = SSL_read_ex(conn, buf + total_read, sizeof(buf) \- total_read,
363 \& if (total_read >= 8192) {
364 \& fprintf(stderr, "Could not fit all data into buffer\en");
372 \& if (!SSL_has_pending(conn))
376 \& fprintf(stderr, "Failed reading remaining data\en");
392 \& if (handle_io_failure(conn, 0) == 1)
394 \& fprintf(stderr, "Failed to write data\en");
408 \& if (ret < 0 && handle_io_failure(conn, ret) == 1)
436 \&\fBossl\-guide\-introduction\fR\|(7), \fBossl\-guide\-libraries\-introduction\fR\|(7),
437 \&\fBossl\-guide\-libssl\-introduction\fR\|(7), \fBossl\-guide\-quic\-introduction\fR\|(7),
438 \&\fBossl\-guide\-quic\-client\-non\-block\fR\|(7), \fBossl\-guide\-quic\-client\-block\fR\|(7),
439 \&\fBossl\-guide\-tls\-server\-block\fR\|(7), \fBossl\-guide\-quic\-server\-block\fR\|(7)
442 Copyright 2024\-2025 The OpenSSL Project Authors. All Rights Reserved.