diff --git a/docs/changes.txt b/docs/changes.txt index ff79140912..1d04f5dcf1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -189,6 +189,7 @@ All: - wxHTTP input stream didn't detect EOF correctly - wxString::find_last_of() ignored "start" parameter (Robert Vazan) - a bug in wxArrayString::Shrink() fixed (Gunnar Roth) +- added wxIPV4address::IPAddress() All (GUI): diff --git a/docs/latex/wx/ipvaddr.tex b/docs/latex/wx/ipvaddr.tex index 1e2fddfdb5..3b7a7e54bd 100644 --- a/docs/latex/wx/ipvaddr.tex +++ b/docs/latex/wx/ipvaddr.tex @@ -42,6 +42,16 @@ Returns TRUE on success, FALSE if something goes wrong Returns the hostname which matches the IP address. +% +% IPAddress +% + +\membersection{wxIPV4address::IPAddress} + +\func{wxString}{IPAddress}{\void} + +Returns a wxString containing the IP address in dot quad (127.0.0.1) format. + % % Service % diff --git a/include/wx/sckaddr.h b/include/wx/sckaddr.h index 5cdc79252c..57ed6dfa8e 100644 --- a/include/wx/sckaddr.h +++ b/include/wx/sckaddr.h @@ -69,6 +69,7 @@ public: wxString Hostname(); wxString OrigHostname() { return m_origHostname; } unsigned short Service(); + wxString IPAddress() const; virtual int Type() { return wxSockAddress::IPV4; } virtual wxSockAddress *Clone() const; diff --git a/src/common/sckaddr.cpp b/src/common/sckaddr.cpp index b75ac6efb5..06fa6a1c47 100644 --- a/src/common/sckaddr.cpp +++ b/src/common/sckaddr.cpp @@ -174,6 +174,18 @@ unsigned short wxIPV4address::Service() return GAddress_INET_GetPort(m_address); } +wxString wxIPV4address::IPAddress() const +{ + unsigned long raw = GAddress_INET_GetHostAddress(m_address); + return wxString::Format( + _T("%u.%u.%u.%u"), + (unsigned char)(raw & 0xff), + (unsigned char)((raw>>8) & 0xff), + (unsigned char)((raw>>16) & 0xff), + (unsigned char)((raw>>24) & 0xff) + ); +} + wxSockAddress *wxIPV4address::Clone() const { wxIPV4address *addr = new wxIPV4address(*this);