#include <connection.h>
Collaboration diagram for Connection:

Public Member Functions | |
| Connection (Parser *parser, const LogSink &logInstance, const std::string &server, int port=-1) | |
| virtual | ~Connection () |
| ConnectionState | connect () |
| ConnectionError | recv (int timeout=-1) |
| void | send (const std::string &data) |
| ConnectionError | receive () |
| void | disconnect (ConnectionError e) |
| bool | isSecure () const |
| ConnectionState | state () const |
| int | fileDescriptor () |
| bool | initCompression (StreamFeature method) |
| void | enableCompression () |
| bool | tlsHandshake () |
| void | setCACerts (const StringList &cacerts) |
| const CertInfo & | fetchTLSInfo () const |
| void | setClientCert (const std::string &clientKey, const std::string &clientCerts) |
Definition at line 52 of file connection.h.
| Connection | ( | Parser * | parser, | |
| const LogSink & | logInstance, | |||
| const std::string & | server, | |||
| int | port = -1 | |||
| ) |
Constructs a new Connection object. You should not need to use this function directly.
| parser | A parser to feed with incoming data. | |
| logInstance | A LogSink to use for logging. | |
| server | A server to connect to. | |
| port | The port to connect to. The default of -1 means that SRV records will be used to find out about the actual host:port. |
Definition at line 48 of file connection.cpp.
| ~Connection | ( | ) | [virtual] |
Virtual destructor
Definition at line 61 of file connection.cpp.
| ConnectionState connect | ( | ) |
Used to initiate the connection.
Definition at line 343 of file connection.cpp.
Referenced by ClientBase::connect().
| void disconnect | ( | ConnectionError | e | ) |
Disconnects an established connection. NOOP if no active connection exists.
| e | A ConnectionError decribing why the connection is terminated. Well, its not really an error here, but... |
Definition at line 380 of file connection.cpp.
Referenced by ClientBase::disconnect().
| void enableCompression | ( | ) |
This function is used to enable stream compression as defined in JEP-0138. It is necessary because when compression is negotiated it is not enabled at once.
Definition at line 334 of file connection.cpp.
| const CertInfo& fetchTLSInfo | ( | ) | const [inline] |
This function is used to retrieve certificate and connection info of a encrypted connection.
Definition at line 159 of file connection.h.
| int fileDescriptor | ( | ) |
Gives access to the raw file descriptor of a connection. Use it wisely. Especially, you should not recv() any data from it. There is no way to feed that back into the parser. You can select()/poll() it and use Connection::recv( -1 ) to fetch the data.
Definition at line 389 of file connection.cpp.
Referenced by ClientBase::fileDescriptor().
| bool initCompression | ( | StreamFeature | method | ) |
This function is used to init or de-init stream compression. You must call this before enabling compression using setCompression().
| method | The desired stream compression method (e.g. zlib, lzw, ...) |
Definition at line 326 of file connection.cpp.
| bool isSecure | ( | ) | const [inline] |
Use this function to determine whether an esatblished connection is encrypted.
Definition at line 109 of file connection.h.
| ConnectionError receive | ( | ) |
Use this function to put the connection into 'receive mode'.
Definition at line 492 of file connection.cpp.
Referenced by ClientBase::connect().
| ConnectionError recv | ( | int | timeout = -1 |
) |
Use this periodically to receive data from the socket and to feed the parser.
| timeout | The timeout to use for select. Default means blocking. |
Definition at line 395 of file connection.cpp.
Referenced by Connection::receive(), and ClientBase::recv().
| void send | ( | const std::string & | data | ) |
Use this function to send a string of data over the wire. The function returns only after all data has been sent.
| data | The data to send. |
Definition at line 508 of file connection.cpp.
| void setCACerts | ( | const StringList & | cacerts | ) | [inline] |
Use this function to set a number of trusted root CA certificates which shall be used to verify a servers certificate.
| cacerts | A list of absolute paths to CA root certificate files in PEM format. |
Definition at line 153 of file connection.h.
Referenced by ClientBase::connect().
| void setClientCert | ( | const std::string & | clientKey, | |
| const std::string & | clientCerts | |||
| ) |
Use this function to set the user's certificate and private key. The certificate will be presented to the server upon request and can be used for SASL EXTERNAL authentication. The user's certificate file should be a bundle of more than one certificate in PEM format. The first one in the file should be the user's certificate, each cert following that one should have signed the previous one.
| clientKey | The absolute path to the user's private key in PEM format. | |
| clientCerts | A path to a certificate bundle in PEM format. |
Definition at line 69 of file connection.cpp.
Referenced by ClientBase::connect().
| ConnectionState state | ( | ) | const [inline] |
Returns the current connection state.
Definition at line 115 of file connection.h.
Referenced by ClientBase::recv(), and ClientBase::state().
| bool tlsHandshake | ( | ) |
Call this function to start a TLS handshake over an established connection.
Definition at line 148 of file connection.cpp.
1.4.7