+wxSockAddress::~wxSockAddress()
+{
+ delete m_impl;
+}
+
+void wxSockAddress::SetAddress(const wxSockAddressImpl& address)
+{
+ if ( &address != m_impl )
+ {
+ delete m_impl;
+ m_impl = new wxSockAddressImpl(address);
+ }
+}
+
+wxSockAddress& wxSockAddress::operator=(const wxSockAddress& addr)
+{
+ SetAddress(addr.GetAddress());
+
+ return *this;
+}
+
+void wxSockAddress::Clear()
+{
+ m_impl->Clear();
+}
+
+// ----------------------------------------------------------------------------
+// wxIPaddress
+// ----------------------------------------------------------------------------
+
+wxSockAddressImpl& wxIPaddress::GetImpl()
+{
+ if ( m_impl->GetFamily() == wxSockAddressImpl::FAMILY_UNSPEC )
+ m_impl->CreateINET();
+
+ return *m_impl;
+}
+
+bool wxIPaddress::Hostname(const wxString& name)
+{
+ wxCHECK_MSG( !name.empty(), false, "empty host name is invalid" );
+
+ m_origHostname = name;
+
+ return GetImpl().SetHostName(name);
+}
+
+bool wxIPaddress::Service(const wxString& name)
+{
+ return GetImpl().SetPortName(name, "tcp");
+}
+
+bool wxIPaddress::Service(unsigned short port)
+{
+ return GetImpl().SetPort(port);
+}
+
+bool wxIPaddress::LocalHost()
+{
+ return Hostname("localhost");
+}
+
+wxString wxIPaddress::Hostname() const
+{
+ return GetImpl().GetHostName();
+}
+
+unsigned short wxIPaddress::Service() const
+{
+ return GetImpl().GetPort();
+}
+
+bool wxIPaddress::operator==(const wxIPaddress& addr) const
+{
+ return Hostname().Cmp(addr.Hostname()) == 0 &&
+ Service() == addr.Service();
+}
+
+bool wxIPaddress::AnyAddress()
+{
+ return GetImpl().SetToAnyAddress();
+}
+
+// ----------------------------------------------------------------------------
+// wxIPV4address
+// ----------------------------------------------------------------------------
+
+void wxIPV4address::DoInitImpl()
+{
+ m_impl->CreateINET();
+}
+
+bool wxIPV4address::Hostname(unsigned long addr)
+{
+ if ( !GetImpl().SetHostAddress(addr) )
+ {
+ m_origHostname.clear();
+ return false;
+ }
+
+ m_origHostname = Hostname();
+ return true;
+}
+
+bool wxIPV4address::IsLocalHost() const
+{
+ return Hostname() == "localhost" || IPAddress() == "127.0.0.1";
+}
+
+wxString wxIPV4address::IPAddress() const
+{
+ wxUint32 addr;
+ if ( !GetImpl().GetHostAddress(&addr) )
+ return wxString();
+
+ return wxString::Format
+ (
+ "%lu.%lu.%lu.%lu",
+ (addr >> 24) & 0xff,
+ (addr >> 16) & 0xff,
+ (addr >> 8) & 0xff,
+ addr & 0xff
+ );
+}
+
+bool wxIPV4address::BroadcastAddress()
+{
+ return GetImpl().SetToBroadcastAddress();
+}
+
+#if wxUSE_IPV6