Nexus HTTP/3
A QUIC and HTTP/3 library
server.hpp
1 #pragma once
2 
3 #include <nexus/udp.hpp>
4 #include <nexus/ssl.hpp>
5 #include <nexus/quic/detail/engine_impl.hpp>
6 #include <nexus/quic/detail/socket_impl.hpp>
7 
8 namespace nexus::quic {
9 
10 class acceptor;
11 class connection;
12 
15 class server {
16  friend class acceptor;
17  detail::engine_impl engine;
18  public:
20  using executor_type = detail::engine_impl::executor_type;
21 
23  explicit server(const executor_type& ex);
24 
26  server(const executor_type& ex, const settings& s);
27 
30 
34  void close();
35 };
36 
39 class acceptor {
40  friend class connection;
41  detail::socket_impl impl;
42  public:
44  using executor_type = detail::socket_impl::executor_type;
45 
47  acceptor(server& s, udp::socket&& socket, ssl::context& ctx);
48 
50  acceptor(server& s, const udp::endpoint& endpoint, ssl::context& ctx);
51 
54 
56  udp::endpoint local_endpoint() const;
57 
61  void listen(int backlog);
62 
65  template <typename CompletionToken> // void(error_code)
66  decltype(auto) async_accept(connection& conn, CompletionToken&& token) {
67  return impl.async_accept(conn, std::forward<CompletionToken>(token));
68  }
69 
72  void accept(connection& conn, error_code& ec);
74  void accept(connection& conn);
75 
77  void close();
78 };
79 
80 } // namespace nexus::quic
a generic QUIC acceptor that owns a UDP socket and uses it to accept and service incoming connections
Definition: server.hpp:39
acceptor(server &s, udp::socket &&socket, ssl::context &ctx)
construct the acceptor, taking ownership of a bound UDP socket
acceptor(server &s, const udp::endpoint &endpoint, ssl::context &ctx)
construct the acceptor and bind a UDP socket to the given endpoint
void accept(connection &conn, error_code &ec)
accept an incoming connection whose TLS handshake has completed successfully
void close()
close the socket, along with any related connections
decltype(auto) async_accept(connection &conn, CompletionToken &&token)
accept an incoming connection whose TLS handshake has completed successfully
Definition: server.hpp:66
void accept(connection &conn)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void listen(int backlog)
start receiving packets on the socket. incoming connections can be accepted with accept()/async_accep...
executor_type get_executor() const
return the associated io executor
udp::endpoint local_endpoint() const
return the socket's locally-bound address/port
detail::socket_impl::executor_type executor_type
the polymorphic executor type, boost::asio::any_io_executor
Definition: server.hpp:44
a generic QUIC connection that can initiate outgoing streams and accept incoming streams
Definition: connection.hpp:14
a generic QUIC server capable of managing one or more UDP sockets via class acceptor
Definition: server.hpp:15
void close()
stop accepting new connections and streams entirely, and mark existing connections as 'going away'....
server(const executor_type &ex, const settings &s)
construct the server with its associated executor and transport settings
server(const executor_type &ex)
construct the server with its associated executor
detail::engine_impl::executor_type executor_type
the polymorphic executor type, boost::asio::any_io_executor
Definition: server.hpp:20
executor_type get_executor() const
return the associated io executor
Generic QUIC library.
Definition: client.hpp:8
quic transport settings used to initialize a client or server
Definition: settings.hpp:16