]> git.saurik.com Git - wxWidgets.git/blob - include/wx/sckaddr.h
added wxSYS_ICONTITLE_FONT (patch 816026)
[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 licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_NETWORK_ADDRESS_H
13 #define _WX_NETWORK_ADDRESS_H
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "sckaddr.h"
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 WXDLLIMPEXP_NET wxSockAddress : public wxObject {
28 DECLARE_ABSTRACT_CLASS(wxSockAddress)
29 public:
30 typedef enum { IPV4=1, IPV6=2, UNIX=3 } Addr;
31
32 wxSockAddress();
33 wxSockAddress(const wxSockAddress& other);
34 virtual ~wxSockAddress();
35
36 wxSockAddress& operator=(const wxSockAddress& other);
37
38 virtual void Clear();
39 virtual int Type() = 0;
40
41 GAddress *GetAddress() const { return m_address; }
42 void SetAddress(GAddress *address);
43
44 // we need to be able to create copies of the addresses polymorphically (i.e.
45 // without knowing the exact address class)
46 virtual wxSockAddress *Clone() const = 0;
47
48 protected:
49 GAddress *m_address;
50
51 private:
52 void Init();
53 };
54
55 class WXDLLIMPEXP_NET wxIPV4address : public wxSockAddress {
56 DECLARE_DYNAMIC_CLASS(wxIPV4address)
57 public:
58 wxIPV4address();
59 wxIPV4address(const wxIPV4address& other);
60 virtual ~wxIPV4address();
61
62 bool Hostname(const wxString& name);
63 bool Hostname(unsigned long addr);
64 bool Service(const wxString& name);
65 bool Service(unsigned short port);
66 bool LocalHost();
67 bool AnyAddress();
68
69 wxString Hostname();
70 wxString OrigHostname() { return m_origHostname; }
71 unsigned short Service();
72 wxString IPAddress() const;
73
74 virtual int Type() { return wxSockAddress::IPV4; }
75 virtual wxSockAddress *Clone() const;
76
77 private:
78 wxString m_origHostname;
79 };
80
81 #ifdef ENABLE_IPV6
82 class WXDLLIMPEXP_NET wxIPV6address : public wxSockAddress {
83 DECLARE_DYNAMIC_CLASS(wxIPV6address)
84 private:
85 struct sockaddr_in6 *m_addr;
86 public:
87 wxIPV6address();
88 wxIPV6address(const wxIPV6address& other);
89 virtual ~wxIPV6address();
90
91 bool Hostname(const wxString& name);
92 bool Hostname(unsigned char addr[16]);
93 bool Service(const wxString& name);
94 bool Service(unsigned short port);
95 bool LocalHost();
96
97 wxString Hostname() const;
98 unsigned short Service() const;
99
100 virtual int Type() { return wxSockAddress::IPV6; }
101 virtual wxSockAddress *Clone() const { return new wxIPV6address(*this); }
102 };
103 #endif
104
105 #if defined(__UNIX__) && !defined(__WINE__) && (!defined(__WXMAC__) || defined(__DARWIN__))
106 #include <sys/socket.h>
107 #ifndef __VMS__
108 # include <sys/un.h>
109 #endif
110
111 class WXDLLIMPEXP_NET wxUNIXaddress : public wxSockAddress {
112 DECLARE_DYNAMIC_CLASS(wxUNIXaddress)
113 private:
114 struct sockaddr_un *m_addr;
115 public:
116 wxUNIXaddress();
117 wxUNIXaddress(const wxUNIXaddress& other);
118 virtual ~wxUNIXaddress();
119
120 void Filename(const wxString& name);
121 wxString Filename();
122
123 virtual int Type() { return wxSockAddress::UNIX; }
124 virtual wxSockAddress *Clone() const { return new wxUNIXaddress(*this); }
125 };
126 #endif
127 // __UNIX__
128
129 #endif
130 // wxUSE_SOCKETS
131
132 #endif
133 // _WX_NETWORK_ADDRESS_H