...one of the most highly
regarded and expertly designed C++ library projects in the
world. — Herb Sutter and Andrei
class is templatized on the stream type. Any object fulfilling the
concept may be used as template argument.
This library provides helper type aliases for the most common cases:
SSL over TCP
Only available if
This example employs a UNIX domain socket to establish a connection to a MySQL server.
Stream template argument
type requirements, you can use the member functions
to establish and finish connections with the MySQL server. If you are using
any of the convenience type aliases (TCP or UNIX, either over TLS or not),
then this is your case.
If your stream type is not based on a socket, you can't use those convenience
member functions. This would be the case if you are using Windows named pipes
Instead, to establish a connection, you should follow these two steps, roughly
equivalent to what
does for sockets:
connection::stream. Use whatever connection establishment mechanism the stream implements. If you are using TLS, you should not perform the TLS handshake yourself, as the library will do it as part of the MySQL handshake.
connection::async_handshake. If the handshake operation fails, close the stream.
To clean up a connection, follow these two steps, roughly equivalent to
connection::async_quit. This will also shutdown TLS, if it's being used.