00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef NHOSTADDRESS_H
00023 #define NHOSTADDRESS_H
00024
00025
00033 #ifndef WIN32_LEAN_AND_MEAN
00034 #define WIN32_LEAN_AND_MEAN
00035 #endif
00036 #include <winsock2.h>
00037
00038 #include "ndefs.h"
00039 #include "nobject.h"
00040 #include "nstring.h"
00041 #include "nlist.h"
00042 #include "nbaseexceptions.h"
00043 #include "nnetworkexceptions.h"
00044 #include "nsignal.h"
00045
00049 class DllDeclSpec NHostAddress: public NObject {
00050 public:
00054 NHostAddress(void);
00055
00060 NHostAddress(const NString &addr);
00061
00067 NHostAddress(const NHostAddress &addr);
00068
00073 NHostAddress(const sockaddr *addr);
00074
00078 void clear(void);
00079
00086 void setAddress(nuint32 ip);
00087
00093 void setAddress(const NString &addr);
00094
00101 void setAddress(const sockaddr *sock);
00102
00113 nuint32 resolve(void) const;
00114
00119 NString toString(void) const;
00120
00126 static NString toString(nuint32 ip);
00127
00132 NString address(void) const;
00133
00138 NList<NString> aliases(void);
00139
00146 NList<nuint32> addresses(void);
00147
00152 bool isNull(void) const;
00153
00158 bool isLocalhost(void) const;
00159
00165 NHostAddress &operator=(const NHostAddress &rhs);
00166
00172 NHostAddress &operator=(const NString &rhs);
00173
00174 private:
00175 NString m_addr;
00176 mutable struct hostent m_host;
00177
00178 void throwErrorByCode(int herr) const;
00179
00180 };
00181
00182 #endif // NHOSTADDRESS_H