1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Network address classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) 1997, 1998 Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_NETWORK_ADDRESS_H
13 #define _WX_NETWORK_ADDRESS_H
23 #include "wx/string.h"
24 #include "wx/gsocket.h"
27 class WXDLLEXPORT wxSockAddress
: public wxObject
{
28 DECLARE_ABSTRACT_CLASS(wxSockAddress
)
30 typedef enum { IPV4
=1, IPV6
=2, UNIX
=3 } Addr
;
33 virtual ~wxSockAddress();
36 virtual int Type() = 0;
38 GAddress
*GetAddress() const { return m_address
; }
39 void SetAddress(GAddress
*address
);
40 const wxSockAddress
& operator =(const wxSockAddress
& addr
);
42 void CopyObject(wxObject
& dest
) const;
48 class WXDLLEXPORT wxIPV4address
: public wxSockAddress
{
49 DECLARE_DYNAMIC_CLASS(wxIPV4address
)
52 virtual ~wxIPV4address();
54 bool Hostname(const wxString
& name
);
55 bool Hostname(unsigned long addr
);
56 bool Service(const wxString
& name
);
57 bool Service(unsigned short port
);
61 unsigned short Service();
63 void Build(struct sockaddr
*& addr
, size_t& len
);
64 void Disassemble(struct sockaddr
*addr
, size_t len
);
66 inline int Type() { return wxSockAddress::IPV4
; }
70 class WXDLLEXPORT wxIPV6address
: public wxSockAddress
{
71 DECLARE_DYNAMIC_CLASS(wxIPV6address
)
73 struct sockaddr_in6
*m_addr
;
78 bool Hostname(const wxString
& name
);
79 bool Hostname(unsigned char addr
[16]);
80 bool Service(const wxString
& name
);
81 bool Service(unsigned short port
);
84 wxString
Hostname() const;
85 unsigned short Service() const;
87 inline int Type() { return wxSockAddress::IPV6
; }
94 class WXDLLEXPORT wxUNIXaddress
: public wxSockAddress
{
95 DECLARE_DYNAMIC_CLASS(wxUNIXaddress
)
97 struct sockaddr_un
*m_addr
;
102 void Filename(const wxString
& name
);
105 inline int Type() { return wxSockAddress::UNIX
; }
114 // _WX_NETWORK_ADDRESS_H