From d95525989dcc5077dec67ece9dc379e534373f7d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 Jul 2003 23:15:00 +0000 Subject: [PATCH] added wxSocket::IPAddress() (patch 694119) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21828 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/latex/wx/ipvaddr.tex | 10 ++++++++++ include/wx/sckaddr.h | 1 + src/common/sckaddr.cpp | 12 ++++++++++++ 4 files changed, 24 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 4f37b4e8e9..db48d4e0e1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -57,6 +57,7 @@ All: and Mac) which contain some tests that were in setup.h - added event sink argument to wxEvtHandler::Connect() - added support for POST method and alt ports to wxHTTP (Roger Chickering) +- added wxSocket::IPAddress() (Chris Mellon) wxBase: diff --git a/docs/latex/wx/ipvaddr.tex b/docs/latex/wx/ipvaddr.tex index b561a33bb6..d78ac3ffb4 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 e1c980f619..adb67509b2 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 66d12c2bd1..80658f3314 100644 --- a/src/common/sckaddr.cpp +++ b/src/common/sckaddr.cpp @@ -181,6 +181,18 @@ wxSockAddress *wxIPV4address::Clone() const return addr; } +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) + ); +} + #if 0 // --------------------------------------------------------------------------- // wxIPV6address -- 2.45.2