rasdaman complete source
akgnet_inetaddr.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community 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 * Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
33 #ifndef AKGNET_INETADDR_HH
34 #define AKGNET_INETADDR_HH
35 
36 #include "akgnet_common.hh"
37 
38 
39 namespace akg
40 {
41 
52 class HostAddress
53 {
54 public:
55  static const uint32_t addrLocalhost = INADDR_LOOPBACK;
56  static const uint32_t addrBroadcast = INADDR_BROADCAST;
57  static const uint32_t addrAny = INADDR_ANY;
58  static const uint32_t addrNone = INADDR_NONE;
59 
61  HostAddress() throw();
62 
64  HostAddress(const HostAddress&);
65 
67  HostAddress(uint32_t);
68 
73  HostAddress(const char* theHostName);
74 
76  ~HostAddress() throw();
77 
79  bool isValid() const throw();
80 
82  const char* getFullHostName() const throw();
83 
85  const char* getShortHostName() const throw();
86 
88  uint32_t getAddress() const throw();
89 
91  const char* getStringAddress() const throw();
92 
93 private:
95  void initDefault() throw();
96 
98  bool init(hostent *);
99 
100  char *fullHostName;
101  char *shortHostName;
102  char *strAddress;
103  in_addr address;
104 
106  HostAddress operator=(const HostAddress&);
107 
108 };
109 
110 
119 class SocketAddress
120 {
121 public:
123  SocketAddress() throw();
124 
126  SocketAddress(sockaddr_in&) throw();
127 
129  void init(sockaddr_in&) throw();
130 
132  bool isValid() const throw();
133 
135  HostAddress getHostAddress() const throw();
136 
138  uint32_t getAddress() const throw();
139  int getPort() const throw();
140 private:
141  bool valid;
142  void clear() throw();
143 
144 private:
145  sockaddr_in address;
146  /*
147  sa_family_t sin_family
148  struct inaddr
149  { uint32_t s_addr;
150  }
151  sin_addr
152  ushort sin_port
153  */
154 };
155 
156 } // namespace
157 #endif