E-MailRelay
glocal.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 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
29namespace 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///
39{
40public:
41 static std::string hostname() ;
42 ///< Returns the local hostname. Returns "localhost" on error.
43
44 static std::string canonicalName() ;
45 ///< Returns the ASCII fully qualified domain name associated with
46 ///< hostname(). The result of the first call is 'memoised'.
47 ///<
48 ///< On Unix the implementation performs a synchronous DNS query
49 ///< on the hostname() and returns the canonical name. The hostname
50 ///< and the returned canonical name are converted to A-labels
51 ///< if necessary.
52 ///<
53 ///< On Windows the 'ComputerNameDnsFullyQualified' value is
54 ///< returned, also converted to A-labels if necessary.
55 ///<
56 ///< Defaults to "<hostname-as-a-label>.localnet" or even
57 ///< "localhost.localnet" if the result would otherwise be
58 ///< invalid.
59
60public:
61 Local() = delete ;
62} ;
63
64#endif
A static class for getting information about the local machine's network name and address.
Definition: glocal.h:39
static std::string canonicalName()
Returns the ASCII fully qualified domain name associated with hostname().
Definition: glocal_unix.cpp:35
static std::string hostname()
Returns the local hostname. Returns "localhost" on error.
Definition: glocal_unix.cpp:27
Network classes.
Definition: gdef.h:1243