Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

any_connection::close (2 of 2 overloads)
PrevUpHomeNext

Cleanly closes the connection to the server.

Synopsis
void
close();
Description

This function does the following:

  • Sends a quit request. This is required by the MySQL protocol, to inform the server that we're closing the connection gracefully.
  • If the connection is using TLS (this->uses_ssl() == true), performs the TLS shutdown.
  • Closes the transport-level connection (the TCP or UNIX socket).

Since this function involves writing a message to the server, it can fail. Only use this function if you know that the connection is healthy and you want to cleanly close it.

If you don't call this function, the destructor or successive connects will perform a transport-layer close. This doesn't cause any resource leaks, but may cause warnings to be written to the server logs.


PrevUpHomeNext