Nexus HTTP/3
A QUIC and HTTP/3 library
client.hpp
1 #pragma once
2 
3 #include <nexus/udp.hpp>
4 #include <nexus/quic/client.hpp>
5 
6 namespace nexus::h3 {
7 
9 class stream;
10 
13 class client {
14  friend class client_connection;
15  quic::detail::engine_impl engine;
16  quic::detail::socket_impl socket;
17  public:
19  using executor_type = quic::detail::engine_impl::executor_type;
20 
22  client(udp::socket&& socket, ssl::context& ctx);
23 
25  client(udp::socket&& socket, ssl::context& ctx,
26  const quic::settings& s);
27 
29  client(const executor_type& ex, const udp::endpoint& endpoint,
30  ssl::context& ctx);
31 
33  client(const executor_type& ex, const udp::endpoint& endpoint,
34  ssl::context& ctx, const quic::settings& s);
35 
38 
40  udp::endpoint local_endpoint() const;
41 
46  const udp::endpoint& endpoint,
47  const char* hostname);
48 
50  void close(error_code& ec);
52  void close();
53 };
54 
58  friend class client;
59  friend class stream;
60  quic::detail::connection_impl impl;
61  public:
63  using executor_type = quic::detail::connection_impl::executor_type;
64 
66  explicit client_connection(client& c) : impl(c.socket) {}
67 
71  client_connection(client& c, const udp::endpoint& endpoint,
72  const char* hostname) : impl(c.socket) {
73  c.connect(*this, endpoint, hostname);
74  }
75 
78 
80  bool is_open() const;
81 
83  quic::connection_id id(error_code& ec) const;
86 
88  udp::endpoint remote_endpoint(error_code& ec) const;
90  udp::endpoint remote_endpoint() const;
91 
93  template <typename CompletionToken> // void(error_code)
94  decltype(auto) async_connect(stream& s, CompletionToken&& token) {
95  return impl.async_connect<stream>(s, std::forward<CompletionToken>(token));
96  }
98  void connect(stream& s, error_code& ec);
100  void connect(stream& s);
101 
103  void go_away(error_code& ec);
105  void go_away();
106 
108  void close(error_code& ec);
110  void close();
111 };
112 
113 } // namespace nexus::h3
an HTTP/3 connection that can initiate outgoing streams and accept server-pushed streams
Definition: client.hpp:57
void go_away(error_code &ec)
send a GOAWAY frame and stop initiating or accepting new streams
client_connection(client &c, const udp::endpoint &endpoint, const char *hostname)
open a connection to the given remote endpoint and hostname. this initiates the TLS handshake,...
Definition: client.hpp:71
void go_away()
This is an overloaded member function, provided for convenience. It differs from the above function o...
client_connection(client &c)
construct a client-side connection for use with connect()
Definition: client.hpp:66
quic::connection_id id(error_code &ec) const
return the connection id if open
quic::detail::connection_impl::executor_type executor_type
the polymorphic executor type, boost::asio::any_io_executor
Definition: client.hpp:63
void close()
This is an overloaded member function, provided for convenience. It differs from the above function o...
executor_type get_executor() const
return the associated io executor
void connect(stream &s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void connect(stream &s, error_code &ec)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void close(error_code &ec)
close the connection, along with any related streams
udp::endpoint remote_endpoint(error_code &ec) const
return the remote's address/port if open
bool is_open() const
determine whether the connection is open
quic::connection_id id() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
decltype(auto) async_connect(stream &s, CompletionToken &&token)
open an outgoing stream
Definition: client.hpp:94
udp::endpoint remote_endpoint() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
an HTTP/3 client that owns a UDP socket and uses it to service client connections
Definition: client.hpp:13
client(const executor_type &ex, const udp::endpoint &endpoint, ssl::context &ctx, const quic::settings &s)
construct the client and bind a UDP socket to the given endpoint
client(udp::socket &&socket, ssl::context &ctx)
construct the client, taking ownership of a bound UDP socket
void close(error_code &ec)
close the socket, along with any related connections
udp::endpoint local_endpoint() const
return the socket's locally-bound address/port
quic::detail::engine_impl::executor_type executor_type
the polymorphic executor type, boost::asio::any_io_executor
Definition: client.hpp:19
executor_type get_executor() const
return the associated io executor
void close()
This is an overloaded member function, provided for convenience. It differs from the above function o...
void connect(client_connection &conn, const udp::endpoint &endpoint, const char *hostname)
open a connection to the given remote endpoint and hostname. this initiates the TLS handshake,...
client(udp::socket &&socket, ssl::context &ctx, const quic::settings &s)
construct the client, taking ownership of a bound UDP socket
client(const executor_type &ex, const udp::endpoint &endpoint, ssl::context &ctx)
construct the client and bind a UDP socket to the given endpoint
a bidirectional HTTP/3 stream that can send and receive HTTP headers, and meets the type requirements...
Definition: stream.hpp:14
an opaque connection id string
Definition: connection_id.hpp:12
HTTP/3 library.
Definition: client.hpp:6
quic transport settings used to initialize a client or server
Definition: settings.hpp:16