00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SOCKETS_Ipv4Address_H
00024 #define _SOCKETS_Ipv4Address_H
00025
00026 #include "sockets-config.h"
00027 #include "SocketAddress.h"
00028
00029
00030 #ifdef SOCKETS_NAMESPACE
00031 namespace SOCKETS_NAMESPACE {
00032 #endif
00033
00034
00035
00036
00037 class Ipv4Address : public SocketAddress
00038 {
00039 public:
00042 Ipv4Address(port_t port = 0);
00046 Ipv4Address(ipaddr_t a,port_t port);
00050 Ipv4Address(struct in_addr& a,port_t port);
00054 Ipv4Address(const std::string& host,port_t port);
00055 Ipv4Address(struct sockaddr_in&);
00056 ~Ipv4Address();
00057
00058
00059
00060 operator struct sockaddr *();
00061 operator socklen_t();
00062 bool operator==(SocketAddress&);
00063
00064 void SetPort(port_t port);
00065 port_t GetPort();
00066
00067 void SetAddress(struct sockaddr *sa);
00068 int GetFamily();
00069
00070 bool IsValid();
00071 std::auto_ptr<SocketAddress> GetCopy();
00072
00074 std::string Convert(bool include_port = false);
00075 std::string Reverse();
00076
00078 static bool Resolve(const std::string& hostname,struct in_addr& a);
00080 static bool Reverse(struct in_addr& a,std::string& name);
00082 static std::string Convert(struct in_addr& a);
00083
00084 private:
00085 Ipv4Address(const Ipv4Address& ) {}
00086 Ipv4Address& operator=(const Ipv4Address& ) { return *this; }
00087 struct sockaddr_in m_addr;
00088 bool m_valid;
00089 };
00090
00091
00092
00093
00094 #ifdef SOCKETS_NAMESPACE
00095 }
00096 #endif
00097 #endif // _SOCKETS_Ipv4Address_H