backported IPAddress() from HEAD (patch 793048)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@23761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-09-20 23:50:10 +00:00
parent 144c947fab
commit 032b711c92
4 changed files with 24 additions and 0 deletions

View File

@@ -189,6 +189,7 @@ All:
- wxHTTP input stream didn't detect EOF correctly - wxHTTP input stream didn't detect EOF correctly
- wxString::find_last_of() ignored "start" parameter (Robert Vazan) - wxString::find_last_of() ignored "start" parameter (Robert Vazan)
- a bug in wxArrayString::Shrink() fixed (Gunnar Roth) - a bug in wxArrayString::Shrink() fixed (Gunnar Roth)
- added wxIPV4address::IPAddress()
All (GUI): All (GUI):

View File

@@ -42,6 +42,16 @@ Returns TRUE on success, FALSE if something goes wrong
Returns the hostname which matches the IP address. 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 % Service
% %

View File

@@ -69,6 +69,7 @@ public:
wxString Hostname(); wxString Hostname();
wxString OrigHostname() { return m_origHostname; } wxString OrigHostname() { return m_origHostname; }
unsigned short Service(); unsigned short Service();
wxString IPAddress() const;
virtual int Type() { return wxSockAddress::IPV4; } virtual int Type() { return wxSockAddress::IPV4; }
virtual wxSockAddress *Clone() const; virtual wxSockAddress *Clone() const;

View File

@@ -174,6 +174,18 @@ unsigned short wxIPV4address::Service()
return GAddress_INET_GetPort(m_address); 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 wxSockAddress *wxIPV4address::Clone() const
{ {
wxIPV4address *addr = new wxIPV4address(*this); wxIPV4address *addr = new wxIPV4address(*this);