E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
GNet::Client Class Referenceabstract

A HeapClient class that adds slot/signal signalling, connection/response timeouts, and input line buffering. More...

`#include <gclient.h>`

Inheritance diagram for GNet::Client:

## Public Member Functions
| Client (const Location &remote_info, unsigned int connection_timeout=0U, unsigned int response_timeout=0U, unsigned int secure_connection_timeout=0U, LineBufferConfig=LineBufferConfig(), bool bind_local_address=false, const Address &local_address=Address::defaultAddress(), bool sync_dns=synchronousDnsDefault())
| Constructor. The connection is initiated asynchronously.
G::Slot::Signal1< std::string > & | doneSignal ()
| Returns a signal that indicates that client processing is complete. More...
G::Slot::Signal2< std::string, std::string > & | eventSignal ()
| Returns a signal that indicates that something interesting has happened. More...
G::Slot::Signal0 & | connectedSignal ()
| Returns a signal that indicates that the client has successfully connected to the server. More...
Public Member Functions inherited from GNet::HeapClient
| HeapClient (const Location &remote_info, bool bind_local_address=false, const Address &local_address=Address::defaultAddress(), bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U)
| Constructor. More...
void | doDelete (const std::string &reason)
| Calls onDelete() and then does a delayed "delete this".
Public Member Functions inherited from GNet::SimpleClient
| SimpleClient (ExceptionHandler &, const Location &remote_info, bool bind_local_address=false, const Address &local_address=Address::defaultAddress(), bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U)
| Constructor. Call connect() to start connecting.
void | connect ()
| Initates a connection to the remote server. More...
bool | connected () const
| Returns true if connected to the peer.
virtual std::pair< bool, Address > | localAddress () const override
| Override from Connection. More...
virtual std::pair< bool, Address > | peerAddress () const override
| Override from Connection. More...
virtual std::string | connectionState () const override
| Returns the connection state display string. More...
virtual std::string | peerCertificate () const override
| Returns the peer's TLS certificate. More...
Location | remoteLocation () const
| Returns a Location structure containing the result of host() and service() name lookup if available. More...
void | updateLocation (const Location &)
| Updates the constructor's Location object with the given one as long as both objects have the same host and service name. More...
virtual void | readEvent () override
| Override from GNet::EventHandler.
virtual void | writeEvent () override
| Override from GNet::EventHandler.
virtual void | otherEvent (EventHandler::Reason) override
| Override from GNet::EventHandler.
bool | send (const std::string &data, std::string::size_type offset=0)
| Sends data to the peer. More...
Public Member Functions inherited from GNet::EventHandler
virtual | ~EventHandler ()
| Destructor.
Public Member Functions inherited from GNet::Connection
virtual | ~Connection ()
| Destructor.

## Protected Member Functions
virtual | ~Client ()
| Destructor.
virtual bool | onReceive (const char *line_data, size_t line_size, size_t eol_size)=0
| Called when a complete line is received from the peer. More...
void | clearInput ()
| Clears the line buffer. More...
std::string | lineBufferEndOfLine () const
| Returns the line buffer end-of-line string. More...
virtual void | onDeleteImp (const std::string &reason) override
| Override from GNet::HeapClient.
virtual void | onConnectImp () override
| Override from GNet::SimpleClient.
virtual void | onData (const char *, SimpleClient::size_type) override
| Override from GNet::SocketProtocolSink.
virtual void | onConnecting () override
| Override from GNet::HeapClient.
virtual void | onSendImp () override
| Override from GNet::SimpleClient.
Protected Member Functions inherited from GNet::HeapClient
virtual | ~HeapClient ()
| Destructor.
void | finish ()
| Indicates that the last data has been sent and the client is expecting a peer disconnect. More...
virtual void | onDelete (const std::string &reason)=0
| Called just before deletion.
virtual void | onException (std::exception &) g__final override
| Override from GNet::ExceptionHandler. More...
Protected Member Functions inherited from GNet::ExceptionHandler
virtual | ~ExceptionHandler ()
| Destructor.
Protected Member Functions inherited from GNet::SimpleClient
virtual | ~SimpleClient ()
| Destructor.
StreamSocket & | socket ()
| Returns a reference to the socket. Throws if not connected.
const StreamSocket & | socket () const
| Returns a const reference to the socket. Throws if not connected.
virtual void | onConnect ()=0
| Called once connected.
virtual void | onSendComplete ()=0
| Called when all residual data from send() has been sent.
void | secureConnect ()
| Starts TLS/SSL client-side negotiation. More...
std::string | logId () const
| Returns a identification string for logging purposes. More...
| SimpleClient (ExceptionHandler &, const Location &remote_info, bool bind_local_address=false, const Address &local_address=Address::defaultAddress(), bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U)
| Constructor. Call connect() to start connecting.
void | connect ()
| Initates a connection to the remote server. More...
bool | connected () const
| Returns true if connected to the peer.
virtual std::pair< bool, Address > | localAddress () const override
| Override from Connection. More...
virtual std::pair< bool, Address > | peerAddress () const override
| Override from Connection. More...
virtual std::string | connectionState () const override
| Returns the connection state display string. More...
virtual std::string | peerCertificate () const override
| Returns the peer's TLS certificate. More...
Location | remoteLocation () const
| Returns a Location structure containing the result of host() and service() name lookup if available. More...
void | updateLocation (const Location &)
| Updates the constructor's Location object with the given one as long as both objects have the same host and service name. More...
virtual void | readEvent () override
| Override from GNet::EventHandler.
virtual void | writeEvent () override
| Override from GNet::EventHandler.
virtual void | otherEvent (EventHandler::Reason) override
| Override from GNet::EventHandler.
bool | send (const std::string &data, std::string::size_type offset=0)
| Sends data to the peer. More...
Protected Member Functions inherited from GNet::EventHandler
virtual | ~EventHandler ()
| Destructor.
Protected Member Functions inherited from GNet::Connection
virtual | ~Connection ()
| Destructor.

## Additional Inherited Members
Public Types inherited from GNet::SimpleClient
enum | ConnectStatus { Success, Failure, ImmediateSuccess }
enum | State { Idle, Resolving, Connecting, Connected, Socksing, Testing }
typedef std::string::size_type | size_type
Public Types inherited from GNet::EventHandler
enum | Reason { reason_closed, reason_down, reason_reset, reason_abort, reason_other }
Static Public Member Functions inherited from GNet::SimpleClient
static bool | synchronousDnsDefault ()
| Returns true if DNS queries should normally be synchronous on this platform. More...
Static Public Member Functions inherited from GNet::EventHandler
static std::string | str (Reason)
| Returns a printable description of the other-event reason. More...
Protected Types inherited from GNet::SimpleClient
enum | ConnectStatus { Success, Failure, ImmediateSuccess }
enum | State { Idle, Resolving, Connecting, Connected, Socksing, Testing }
typedef std::string::size_type | size_type
Protected Types inherited from GNet::EventHandler
enum | Reason { reason_closed, reason_down, reason_reset, reason_abort, reason_other }
Static Protected Member Functions inherited from GNet::SimpleClient
static bool | connectError (const std::string &reason)
| Returns true if the reason string implies the SimpleClient::connect() failed. More...
static bool | synchronousDnsDefault ()
| Returns true if DNS queries should normally be synchronous on this platform. More...
Static Protected Member Functions inherited from GNet::EventHandler
static std::string | str (Reason)
| Returns a printable description of the other-event reason. More...

## Detailed Description

A HeapClient class that adds slot/signal signalling, connection/response timeouts, and input line buffering.

The following pure virtual functions must be implemented by derived classes: onConnect(), onReceive(), onDelete(), and onSendComplete().

The intention is that derived classes use the virtual functions for event notification while the slot/signal event notifications are used by the containing object (in particular so that the container is informed when the client object deletes itself).

Definition at line 48 of file gclient.h.

## Member Function Documentation

void GNet::Client::clearInput | ( |  | ) |
| protected

Clears the line buffer.

This discards any data that has been received from the server but not delivered as a complete line via onReceive().

Definition at line 120 of file gclient.cpp.

G::Slot::Signal0 & GNet::Client::connectedSignal | ( |  | ) |

Returns a signal that indicates that the client has successfully connected to the server.

Definition at line 94 of file gclient.cpp.

G::Slot::Signal1< std::string > & GNet::Client::doneSignal | ( |  | ) |

Returns a signal that indicates that client processing is complete.

The signal parameter is a failure reason, or the empty string on success.

Definition at line 84 of file gclient.cpp.

G::Slot::Signal2< std::string, std::string > & GNet::Client::eventSignal | ( |  | ) |

Returns a signal that indicates that something interesting has happened.

The first signal parameter is one of "connecting", "connected", and either "failed" (on error) or "done" (for normal termination). The "done/failed" event is emitted just before the doneSignal(). Derived clases may emit other events over this channel.

Definition at line 89 of file gclient.cpp.

std::string GNet::Client::lineBufferEndOfLine | ( |  | ) | const
| protected

Returns the line buffer end-of-line string.

Returns the empty string if auto-detecting and not yet auto-detected.

Definition at line 115 of file gclient.cpp.

virtual bool GNet::Client::onReceive | ( | const char * | line_data,
|  | size_t | line_size,
|  | size_t | eol_size
| ) |  |
| protected pure virtual

Called when a complete line is received from the peer.

The implementation should return false if it needs to stop further onReceive() calls being generated from data already received and buffered, if for example the object has just deleted itself.

Implemented in GSmtp::Client, GSmtp::RequestClient, and GSmtp::SpamClient.

The documentation for this class was generated from the following files:

- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/gnet/gclient.h
- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/gnet/gclient.cpp