00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _SOCKETS_Ipv4Address_H
00034 #define _SOCKETS_Ipv4Address_H
00035
00036 #include "sockets-config.h"
00037 #include "SocketAddress.h"
00038
00039
00040 #ifdef SOCKETS_NAMESPACE
00041 namespace SOCKETS_NAMESPACE {
00042 #endif
00043
00044
00045
00046
00047 class Ipv4Address : public SocketAddress
00048 {
00049 public:
00052 Ipv4Address(port_t port = 0);
00056 Ipv4Address(ipaddr_t a,port_t port);
00060 Ipv4Address(struct in_addr& a,port_t port);
00064 Ipv4Address(const std::string& host,port_t port);
00065 Ipv4Address(struct sockaddr_in&);
00066 ~Ipv4Address();
00067
00068
00069
00070 operator struct sockaddr *();
00071 operator socklen_t();
00072 bool operator==(SocketAddress&);
00073
00074 void SetPort(port_t port);
00075 port_t GetPort();
00076
00077 void SetAddress(struct sockaddr *sa);
00078 int GetFamily();
00079
00080 bool IsValid();
00081 std::auto_ptr<SocketAddress> GetCopy();
00082
00084 std::string Convert(bool include_port = false);
00085 std::string Reverse();
00086
00088 static bool Resolve(const std::string& hostname,struct in_addr& a);
00090 static bool Reverse(struct in_addr& a,std::string& name);
00092 static std::string Convert(struct in_addr& a);
00093
00094 private:
00095 Ipv4Address(const Ipv4Address& ) {}
00096 Ipv4Address& operator=(const Ipv4Address& ) { return *this; }
00097 struct sockaddr_in m_addr;
00098 bool m_valid;
00099 };
00100
00101
00102
00103
00104 #ifdef SOCKETS_NAMESPACE
00105 }
00106 #endif
00107 #endif // _SOCKETS_Ipv4Address_H
00108