- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
48 class GNet::ResolverInfo
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
86 G::DateTime::EpochTime updateTime() const ;
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
GNet::ResolverInfo::update
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()...
Definition: gresolverinfo.cpp:98
G::DateTime::EpochTime
std::time_t EpochTime
Definition: gdatetime.h:41
GNet
Network classes.
GNet::ResolverInfo::socksFarHost
std::string socksFarHost() const
Returns the port for the socks far server.
Definition: gresolverinfo.cpp:148
GNet::Address
The Address class encapsulates an IP transport address.
Definition: gaddress.h:48
GNet::ResolverInfo
A class that holds a host/service name pair and optionally the results of a name-to-address lookup...
Definition: gresolverinfo.h:48
GNet::ResolverInfo::ResolverInfo
ResolverInfo(const std::string &host, const std::string &service)
Constructor.
Definition: gresolverinfo.cpp:67
GNet::ResolverInfo::socksFarPort
unsigned int socksFarPort() const
Returns the port number for the socks far server.
Definition: gresolverinfo.cpp:143
GNet::ResolverInfo::address
Address address() const
Returns the remote address.
Definition: gresolverinfo.cpp:93
GNet::ResolverInfo::hasAddress
bool hasAddress() const
Returns true after update() has been called.
Definition: gresolverinfo.cpp:88
GNet::ResolverInfo::socks
bool socks() const
Returns true if using socks.
Definition: gresolverinfo.cpp:138
GNet::ResolverInfo::str
std::string str() const
Returns a string representation of the host and service names that can be passed to the Resolver's re...
Definition: gresolverinfo.cpp:111
gdatetime.h
gexception.h
G_EXCEPTION
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
GNet::ResolverInfo::displayString
std::string displayString(bool simple=false) const
Returns a string representation for logging and debug.
Definition: gresolverinfo.cpp:116
GNet::ResolverInfo::service
std::string service() const
Returns the remote service name, as passed in to the constructor.
Definition: gresolverinfo.cpp:83
gaddress.h
GNet::ResolverInfo::updateTime
G::DateTime::EpochTime updateTime() const
Returns the time of the last update().
Definition: gresolverinfo.cpp:133
GNet::ResolverInfo::name
std::string name() const
Returns the remote canonical name.
Definition: gresolverinfo.cpp:106
GNet::ResolverInfo::host
std::string host() const
Returns the remote host name, as passed in to the constructor.
Definition: gresolverinfo.cpp:78