- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
GNet::ResolverImp Class Reference

A pimple-pattern implementation class for GNet::Resolver. More...

Inheritance diagram for GNet::ResolverImp:

## Public Member Functions
| ResolverImp (EventHandler &event_handler, Resolver &resolver, unsigned int port)
virtual | ~ResolverImp ()
bool | resolveReq (std::string host_part, std::string service_part, bool udp)
bool | busy () const
Public Member Functions inherited from GNet::SimpleClient
| SimpleClient (const ResolverInfo &remote_info, const Address &local_address=Address(0U), bool privileged=false, bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U)
| Constructor. More...
void | connect ()
| Initates a connection to the remote server. More...
bool | connected () const
| Returns true if connected to the peer. More...
virtual std::pair< bool, Address > | localAddress () const
| Override from Connection. More...
virtual std::pair< bool, Address > | peerAddress () const
| Override from Connection. More...
virtual std::string | peerCertificate () const
| Returns the peer's TLS certificate. More...
ResolverInfo | resolverInfo () const
| Returns a ResolverInfo structure containing the result of host() and service() name lookup if available. More...
void | updateResolverInfo (const ResolverInfo &)
| Updates the constructor's ResolverInfo object with the given one as long as both objects have the same host and service name. More...
virtual void | readEvent ()
| Final override from GNet::EventHandler. More...
virtual void | writeEvent ()
| Final override from GNet::EventHandler. More...
bool | send (const std::string &data, std::string::size_type offset=0)
| Returns true if all sent, or false if flow control was asserted. More...
Public Member Functions inherited from GNet::EventHandler
virtual | ~EventHandler ()
| Destructor. More...
virtual void | exceptionEvent ()
| Called for an exception event. More...
Public Member Functions inherited from GNet::Connection
virtual | ~Connection ()
| Destructor. More...
Public Member Functions inherited from GNet::SocketProtocolSink
virtual | ~SocketProtocolSink ()
| Destructor. More...

## Protected Member Functions
virtual void | onConnect ()
| Called once connected. More...
virtual void | onSendComplete ()
| Called when all residual data from send() has been sent. More...
virtual void | onData (const char *, std::string::size_type)
| Called when data is read from the socket. More...
virtual void | onSecure (const std::string &)
| Called once the secure socket protocol has been successfully negotiated. More...
virtual void | onException (std::exception &)
| Called when an exception is thrown out of readEvent(), writeEvent() or exceptionEvent(). More...
Protected Member Functions inherited from GNet::SimpleClient
virtual | ~SimpleClient ()
| Destructor. More...
StreamSocket & | socket ()
| Returns a reference to the socket. Throws if not connected. More...
const StreamSocket & | socket () const
| Returns a const reference to the socket. Throws if not connected. More...
virtual void | onConnectImp ()
| An alternative to onConnect() for private implementation classes. More...
virtual void | onSendImp ()
| Called from within send(). More...
void | sslConnect ()
| Starts TLS/SSL client-side negotiation. More...
std::string | logId () const
| Returns a identification string for logging purposes. More...

## Additional Inherited Members
Public Types inherited from GNet::SimpleClient
enum | ConnectStatus { Success, Failure, Retry, ImmediateSuccess }
enum | State { Idle, Resolving, Connecting, Connected, Socksing }
typedef std::string::size_type | size_type
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 Protected Member Functions inherited from GNet::SimpleClient
static bool | canRetry (const std::string &reason)
| Parses the given failure reason and returns true if the client can reasonably retry at some later time. More...

## Detailed Description

A pimple-pattern implementation class for GNet::Resolver.

Note that the implementation uses GNet::SimpleClient even though GNet::SimpleClient uses a resolver. This is possible because this class passes a fully-resolved ResolverInfo object to the client and the client class only instantiates a resolver when necessary.

Definition at line 49 of file gresolver_unix.cpp.

## Constructor & Destructor Documentation

GNet::ResolverImp::ResolverImp | ( | EventHandler & | event_handler,
|  | Resolver & | resolver,
|  | unsigned int | port
| ) |  |

Definition at line 85 of file gresolver_unix.cpp.

GNet::ResolverImp::~ResolverImp | ( |  | ) |
| virtual

Definition at line 92 of file gresolver_unix.cpp.

## Member Function Documentation

bool GNet::ResolverImp::busy | ( |  | ) | const

Definition at line 171 of file gresolver_unix.cpp.

void GNet::ResolverImp::onConnect | ( |  | ) |
| protected virtual

Called once connected.

May (unfortunately) be called from within connect().

Implements GNet::SimpleClient.

Definition at line 117 of file gresolver_unix.cpp.

void GNet::ResolverImp::onData | ( | const char * | ,
|  | std::string::size_type |
| ) |  |
| protected virtual

Called when data is read from the socket.

Implements GNet::SocketProtocolSink.

Definition at line 131 of file gresolver_unix.cpp.

References G_DEBUG, GNet::Address::invalidAddress(), G::Str::isPrintableAscii(), G::Str::trim(), and GNet::Address::validString().

void GNet::ResolverImp::onException | ( | std::exception & |  | ) |
| protected virtual

Called when an exception is thrown out of readEvent(), writeEvent() or exceptionEvent().

The implementation may just do a "throw" to throw the current exception out of the event loop, or a "delete this" for objects that manage themselves on the heap.

EventHandler objects or timer objects that are sub-objects of other EventHandler objects will normally have their implementation of onException() or onTimeoutException() delgate to the outer object's onException().

Implements GNet::EventHandler.

Definition at line 158 of file gresolver_unix.cpp.

References GNet::Address::invalidAddress().

void GNet::ResolverImp::onSecure | ( | const std::string & | peer_certificate | ) |
| protected virtual

Called once the secure socket protocol has been successfully negotiated.

Implements GNet::SocketProtocolSink.

Definition at line 127 of file gresolver_unix.cpp.

void GNet::ResolverImp::onSendComplete | ( |  | ) |
| protected virtual

Called when all residual data from send() has been sent.

Implements GNet::SimpleClient.

Definition at line 123 of file gresolver_unix.cpp.

bool GNet::ResolverImp::resolveReq | ( | std::string | host_part,
|  | std::string | service_part,
|  | bool | udp
| ) |  |

Definition at line 103 of file gresolver_unix.cpp.

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

- gresolver_unix.cpp