]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckaddr.h
wxTheApp can't be assigned to, anyhow, so make ms_appInstance private and provide...
[wxWidgets.git] / include / wx / sckaddr.h
CommitLineData
f4ada568
GL
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
371a5b4e 9// Licence: wxWindows licence
f4ada568 10/////////////////////////////////////////////////////////////////////////////
2df7be7f 11
f4ada568
GL
12#ifndef _WX_NETWORK_ADDRESS_H
13#define _WX_NETWORK_ADDRESS_H
14
af49c4b8
GD
15#if defined(__GNUG__) && !defined(__APPLE__)
16#pragma interface "sckaddr.h"
2df7be7f
RR
17#endif
18
19#include "wx/defs.h"
20
21#if wxUSE_SOCKETS
22
2df7be7f 23#include "wx/string.h"
65ccd2b8 24#include "wx/gsocket.h"
a324a7bc 25
f4ada568 26
7c4728f6 27class WXDLLIMPEXP_NET wxSockAddress : public wxObject {
f4ada568
GL
28 DECLARE_ABSTRACT_CLASS(wxSockAddress)
29public:
30 typedef enum { IPV4=1, IPV6=2, UNIX=3 } Addr;
31
a324a7bc 32 wxSockAddress();
1539c2f5 33 wxSockAddress(const wxSockAddress& other);
a324a7bc
GL
34 virtual ~wxSockAddress();
35
1539c2f5
VZ
36 wxSockAddress& operator=(const wxSockAddress& other);
37
a324a7bc
GL
38 virtual void Clear();
39 virtual int Type() = 0;
f4ada568 40
a324a7bc
GL
41 GAddress *GetAddress() const { return m_address; }
42 void SetAddress(GAddress *address);
f4ada568 43
acd15a3f 44 // we need to be able to create copies of the addresses polymorphically (i.e.
6c0d0845 45 // without knowing the exact address class)
acd15a3f 46 virtual wxSockAddress *Clone() const = 0;
f4ada568 47
a324a7bc
GL
48protected:
49 GAddress *m_address;
6c0d0845
VZ
50
51private:
52 void Init();
f4ada568
GL
53};
54
7c4728f6 55class WXDLLIMPEXP_NET wxIPV4address : public wxSockAddress {
f4ada568 56 DECLARE_DYNAMIC_CLASS(wxIPV4address)
f4ada568
GL
57public:
58 wxIPV4address();
1539c2f5 59 wxIPV4address(const wxIPV4address& other);
f4ada568
GL
60 virtual ~wxIPV4address();
61
a324a7bc
GL
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();
636c47a7 67 bool AnyAddress();
f4ada568
GL
68
69 wxString Hostname();
ce22d615 70 wxString OrigHostname() { return m_origHostname; }
f4ada568 71 unsigned short Service();
d9552598 72 wxString IPAddress() const;
f4ada568 73
acd15a3f 74 virtual int Type() { return wxSockAddress::IPV4; }
ce22d615
RD
75 virtual wxSockAddress *Clone() const;
76
77private:
78 wxString m_origHostname;
f4ada568
GL
79};
80
81#ifdef ENABLE_IPV6
7c4728f6 82class WXDLLIMPEXP_NET wxIPV6address : public wxSockAddress {
f4ada568
GL
83 DECLARE_DYNAMIC_CLASS(wxIPV6address)
84private:
85 struct sockaddr_in6 *m_addr;
86public:
87 wxIPV6address();
1539c2f5
VZ
88 wxIPV6address(const wxIPV6address& other);
89 virtual ~wxIPV6address();
f4ada568 90
f4ada568
GL
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
acd15a3f
VZ
100 virtual int Type() { return wxSockAddress::IPV6; }
101 virtual wxSockAddress *Clone() const { return new wxIPV6address(*this); }
f4ada568
GL
102};
103#endif
104
5283098e 105#if defined(__UNIX__) && !defined(__WINE__) && (!defined(__WXMAC__) || defined(__DARWIN__))
fd9811b1 106#include <sys/socket.h>
e1c70641
JJ
107#ifndef __VMS__
108# include <sys/un.h>
109#endif
f4ada568 110
7c4728f6 111class WXDLLIMPEXP_NET wxUNIXaddress : public wxSockAddress {
f4ada568
GL
112 DECLARE_DYNAMIC_CLASS(wxUNIXaddress)
113private:
114 struct sockaddr_un *m_addr;
115public:
116 wxUNIXaddress();
1539c2f5
VZ
117 wxUNIXaddress(const wxUNIXaddress& other);
118 virtual ~wxUNIXaddress();
f4ada568 119
f4ada568
GL
120 void Filename(const wxString& name);
121 wxString Filename();
122
acd15a3f
VZ
123 virtual int Type() { return wxSockAddress::UNIX; }
124 virtual wxSockAddress *Clone() const { return new wxUNIXaddress(*this); }
f4ada568
GL
125};
126#endif
2df7be7f 127 // __UNIX__
f4ada568
GL
128
129#endif
2df7be7f 130 // wxUSE_SOCKETS
65ccd2b8 131
2df7be7f
RR
132#endif
133 // _WX_NETWORK_ADDRESS_H