/////////////////////////////////////////////////////////////////////////////
-// Name: sckaddr.h
+// Name: wx/sckaddr.h
// Purpose: Network address classes
// Author: Guilhem Lavaux
// Modified by:
class wxSockAddressImpl;
+// forward declare it instead of including the system headers defining it which
+// can bring in <windows.h> under Windows which we don't want to include from
+// public wx headers
+struct sockaddr;
+
// Any socket address kind
class WXDLLIMPEXP_NET wxSockAddress : public wxObject
{
virtual void Clear();
virtual Family Type() = 0;
+ // accessors for the low level address represented by this object
+ const sockaddr *GetAddressData() const;
+ int GetAddressDataLen() const;
+
// we need to be able to create copies of the addresses polymorphically
// (i.e. without knowing the exact address class)
virtual wxSockAddress *Clone() const = 0;
Returns the length of the socket address.
*/
int SockAddrLen();
+
+ /**
+ Returns the pointer to the low-level representation of the address.
+
+ This can be used to pass socket address information to a 3rd party
+ library.
+
+ @return
+ Pointer to a sockaddr-derived struct.
+ */
+ const sockaddr *GetAddressData() const;
+
+ /**
+ Returns the length of the buffer retrieved by GetAddressData().
+
+ @return
+ The size of the sockaddr-derived struct corresponding to this
+ address.
+ */
+ int GetAddressDataLen() const;
};
// wxSockAddress
// ----------------------------------------------------------------------------
+const sockaddr *wxSockAddress::GetAddressData() const
+{
+ return GetAddress().GetAddr();
+}
+
+int wxSockAddress::GetAddressDataLen() const
+{
+ return GetAddress().GetLen();
+}
+
void wxSockAddress::Init()
{
if ( !wxSocketBase::IsInitialized() )