]> git.saurik.com Git - wxWidgets.git/blob - include/wx/sckaddr.h
some changes to make wxHtmlHelpController easier to subclass
[wxWidgets.git] / include / wx / sckaddr.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: sckaddr.h
3 // Purpose: Network address classes
4 // Author: Guilhem Lavaux
5 // Modified by:
6 // Created: 26/04/1997
7 // RCS-ID: $Id$
8 // Copyright: (c) 1997, 1998 Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_NETWORK_ADDRESS_H
13 #define _WX_NETWORK_ADDRESS_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_SOCKETS
22
23 #include "wx/string.h"
24 #include "wx/gsocket.h"
25
26
27 class WXDLLEXPORT wxSockAddress : public wxObject {
28 DECLARE_ABSTRACT_CLASS(wxSockAddress)
29 public:
30 typedef enum { IPV4=1, IPV6=2, UNIX=3 } Addr;
31
32 wxSockAddress();
33 virtual ~wxSockAddress();
34
35 virtual void Clear();
36 virtual int Type() = 0;
37
38 GAddress *GetAddress() const { return m_address; }
39 void SetAddress(GAddress *address);
40 const wxSockAddress& operator =(const wxSockAddress& addr);
41
42 void CopyObject(wxObject& dest) const;
43
44 protected:
45 GAddress *m_address;
46 };
47
48 class WXDLLEXPORT wxIPV4address : public wxSockAddress {
49 DECLARE_DYNAMIC_CLASS(wxIPV4address)
50 public:
51 wxIPV4address();
52 virtual ~wxIPV4address();
53
54 bool Hostname(const wxString& name);
55 bool Hostname(unsigned long addr);
56 bool Service(const wxString& name);
57 bool Service(unsigned short port);
58 bool LocalHost();
59
60 wxString Hostname();
61 unsigned short Service();
62
63 void Build(struct sockaddr*& addr, size_t& len);
64 void Disassemble(struct sockaddr *addr, size_t len);
65
66 inline int Type() { return wxSockAddress::IPV4; }
67 };
68
69 #ifdef ENABLE_IPV6
70 class WXDLLEXPORT wxIPV6address : public wxSockAddress {
71 DECLARE_DYNAMIC_CLASS(wxIPV6address)
72 private:
73 struct sockaddr_in6 *m_addr;
74 public:
75 wxIPV6address();
76 ~wxIPV6address();
77
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);
82 bool LocalHost();
83
84 wxString Hostname() const;
85 unsigned short Service() const;
86
87 inline int Type() { return wxSockAddress::IPV6; }
88 };
89 #endif
90
91 #ifdef __UNIX__
92 #include <sys/socket.h>
93 #include <sys/un.h>
94
95 class WXDLLEXPORT wxUNIXaddress : public wxSockAddress {
96 DECLARE_DYNAMIC_CLASS(wxUNIXaddress)
97 private:
98 struct sockaddr_un *m_addr;
99 public:
100 wxUNIXaddress();
101 ~wxUNIXaddress();
102
103 void Filename(const wxString& name);
104 wxString Filename();
105
106 inline int Type() { return wxSockAddress::UNIX; }
107 };
108 #endif
109 // __UNIX__
110
111 #endif
112 // wxUSE_SOCKETS
113
114 #endif
115 // _WX_NETWORK_ADDRESS_H