gresolverinfo.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
20 
21 #ifndef G_RESOLVER_INFO_H
22 #define G_RESOLVER_INFO_H
23 
24 #include "gdef.h"
25 #include "gnet.h"
26 #include "gaddress.h"
27 #include "gdatetime.h"
28 #include "gexception.h"
29 
31 namespace GNet
32 {
33  class ResolverInfo ;
34  class Resolver ;
35 }
36 
49 {
50 public:
51  G_EXCEPTION( InvalidFormat , "invalid host:service format" ) ;
52 
53  ResolverInfo( const std::string & host , const std::string & service ) ;
55 
56  ResolverInfo( const std::string & host_and_service ) ;
58 
59  std::string host() const ;
61 
62  std::string service() const ;
64 
65  void update( const Address & address , const std::string & canonical_name ) ;
68 
69  bool hasAddress() const ;
71 
72  Address address() const ;
74 
75  std::string name() const ;
78 
79  std::string str() const ;
82 
83  std::string displayString( bool simple = false ) const ;
85 
89 
90  bool socks() const ;
92 
93  unsigned int socksFarPort() const ;
95 
96  std::string socksFarHost() const ;
98 
99 private:
100  static std::string part( const std::string & , bool ) ;
101  static bool socked( const std::string & , std::string & , unsigned int & ) ;
102  static std::string sockless( const std::string & ) ;
103 
104 private:
105  std::string m_host ;
106  std::string m_service ;
107  bool m_address_valid ;
108  Address m_address ;
109  std::string m_canonical_name ;
110  G::DateTime::EpochTime m_update_time ;
111  bool m_socks ;
112  std::string m_socks_far_host ;
113  unsigned int m_socks_far_port ;
114 } ;
115 
116 #endif
void update(const Address &address, const std::string &canonical_name)
Updates the address and canonical name, typically after doing a name lookup on host() and service()...
std::time_t EpochTime
Definition: gdatetime.h:41
Network classes.
std::string socksFarHost() const
Returns the port for the socks far server.
The Address class encapsulates an IP transport address.
Definition: gaddress.h:48
A class that holds a host/service name pair and optionally the results of a name-to-address lookup...
Definition: gresolverinfo.h:48
ResolverInfo(const std::string &host, const std::string &service)
Constructor.
unsigned int socksFarPort() const
Returns the port number for the socks far server.
Address address() const
Returns the remote address.
bool hasAddress() const
Returns true after update() has been called.
bool socks() const
Returns true if using socks.
std::string str() const
Returns a string representation of the host and service names that can be passed to the Resolver's re...
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
std::string displayString(bool simple=false) const
Returns a string representation for logging and debug.
std::string service() const
Returns the remote service name, as passed in to the constructor.
G::DateTime::EpochTime updateTime() const
Returns the time of the last update().
std::string name() const
Returns the remote canonical name.
std::string host() const
Returns the remote host name, as passed in to the constructor.