E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

glocal.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 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 // ===
17 ///
18 /// \file glocal.h
19 ///
20
21 #ifndef G_NET_LOCAL__H
22 #define G_NET_LOCAL__H
23
24 #include "gdef.h"
25 #include "gaddress.h"
26 #include "glocation.h"
27 #include "gexception.h"
28
29 namespace GNet
30 {
31 class Local ;
32 }
33
34 /// \class GNet::Local
35 /// A static class for getting information about the local machine's network
36 /// name and address.
37 ///
38 class GNet::Local
39 {
40 public:
41 static std::string hostname() ;
42 ///< Returns the local hostname. Returns "localhost" on error.
43
44 static std::string canonicalName() ;
45 ///< Returns the canonical network name assiciated with hostname().
46 ///< Defaults to "<hostname>.localnet" if DNS does not provide
47 ///< a canonical network name.
48
49 static void canonicalName( const std::string & override ) ;
50 ///< Sets the canonicalName() override.
51
52 static bool isLocal( const Address & , std::string & reason ) ;
53 ///< Returns true if the given address appears to be associated
54 ///< with the local host, or a helpful error message if not.
55
56 private:
57 Local() ;
58 static std::string resolvedHostname() ;
59
60 private:
61 static std::string m_name_override ;
62 static bool m_name_override_set ;
63 } ;
64
65 #endif
GNet::Local::canonicalName
static std::string canonicalName()
Returns the canonical network name assiciated with hostname().
Definition: glocal.cpp:54
GNet::Local::hostname
static std::string hostname()
Returns the local hostname. Returns "localhost" on error.
Definition: glocal.cpp:32
GNet
Network classes.
Definition: gaddress.h:29
GNet::Address
The GNet::Address class encapsulates a TCP/UDP transport address.
Definition: gaddress.h:54
glocation.h
GNet::Local
A static class for getting information about the local machine's network name and address...
Definition: glocal.h:38
GNet::Local::isLocal
static bool isLocal(const Address &, std::string &reason)
Returns true if the given address appears to be associated with the local host, or a helpful error me...
Definition: glocal.cpp:65
gexception.h
gaddress.h