00001
00002 #ifndef header_ip_address
00003 #define header_ip_address
00004
00006
00007 #include <string>
00008
00009 class CL_IPAddress
00010
00011 {
00013 public:
00014 CL_IPAddress();
00015
00016
00017 CL_IPAddress(unsigned int address, unsigned short port);
00018
00019
00020 CL_IPAddress(const std::string &hostname, unsigned short port);
00021
00022
00023 CL_IPAddress(const CL_IPAddress ©);
00024
00025
00027 public:
00028 unsigned int get_address() const { return ip; }
00029
00030
00031 unsigned short get_port() const { return port; }
00032
00033
00034 unsigned char &operator[](int i) { return ((unsigned char*) &ip)[i]; }
00035
00036
00037 const unsigned char &operator[](int i) const { return ((unsigned char*) &ip)[i]; }
00038
00039
00041 public:
00042 void set_address(unsigned int new_ip) { ip = new_ip; }
00043
00044
00045 void set_address(const std::string &hostname);
00046
00047
00048 void set_port(unsigned short new_port) { port = new_port; }
00049
00050
00051 std::string dns_lookup() const;
00052
00053
00055 private:
00056 unsigned int ip;
00057
00058
00059 unsigned short port;
00060
00061 };
00062
00063 #endif