Connection
for TCP/IP.
More...
#include <tcp_connection.h>
Inheritance diagram for mysqlpp::TCPConnection:
Public Member Functions | |
TCPConnection () | |
Create object without connecting it to the MySQL server. | |
TCPConnection (const char *addr, const char *db=0, const char *user=0, const char *password=0) | |
Create object and connect to database server over TCP/IP in one step. | |
TCPConnection (const TCPConnection &other) | |
Establish a new connection using the same parameters as an existing connection. | |
~TCPConnection () | |
Destroy object. | |
bool | connect (const char *addr=0, const char *db=0, const char *user=0, const char *password=0) |
Connect to database after object is created. | |
Static Public Member Functions | |
static bool | parse_address (std::string &addr, unsigned int &port, std::string &error) |
Break the given TCP/IP address up into a separate address and port form. |
Connection
for TCP/IP.
This class just simplifies the connection creation interface of Connection
. It does not add new functionality.
mysqlpp::TCPConnection::TCPConnection | ( | const char * | addr, | |
const char * | db = 0 , |
|||
const char * | user = 0 , |
|||
const char * | password = 0 | |||
) | [inline] |
Create object and connect to database server over TCP/IP in one step.
addr | TCP/IP address of server, in either dotted quad form or as a host or domain name; may be followed by a colon and a port number or service name to override default port | |
db | name of database to use | |
user | user name to log in under, or 0 to use the user name the program is running under | |
password | password to use when logging in |
mysqlpp::TCPConnection::TCPConnection | ( | const TCPConnection & | other | ) | [inline] |
Establish a new connection using the same parameters as an existing connection.
other | pre-existing connection to clone |
bool mysqlpp::TCPConnection::connect | ( | const char * | addr = 0 , |
|
const char * | db = 0 , |
|||
const char * | user = 0 , |
|||
const char * | password = 0 | |||
) |
Connect to database after object is created.
It's better to use the connect-on-create constructor if you can. See its documentation for the meaning of these parameters.
If you call this method on an object that is already connected to a database server, the previous connection is dropped and a new connection is established.
bool mysqlpp::TCPConnection::parse_address | ( | std::string & | addr, | |
unsigned int & | port, | |||
std::string & | error | |||
) | [static] |
Break the given TCP/IP address up into a separate address and port form.
Does some sanity checking on the address. Only intended to try and prevent library misuse, not ensure that the address can actually be used to contact a server.
It understands the following forms:
It also understands IPv6 addresses, but to avoid confusion between the colons they use and the colon separating the address part from the service/port part, they must be in RFC 2732 form. Example: [2010:836B:4179::836B:4179]:1234
addr | the address and optional port/service combo to check on input, and the verified address on successful return | |
port | the port number (resolved from the service name if necessary) on successful return | |
error | on false return, reason for failure is placed here |