]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckaddr.h
Added WXHTREEITEM
[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
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11#ifndef _WX_NETWORK_ADDRESS_H
12#define _WX_NETWORK_ADDRESS_H
13
14#if defined(__WINDOWS__) && defined(WXSOCK_INTERNAL)
15#include <winsock.h>
16
17#elif defined(__UNIX__) && defined(WXSOCK_INTERNAL)
18
19#include <sys/types.h>
20#include <sys/socket.h>
21#include <netinet/in.h>
22#endif
23
24#ifdef __GNUG__
25#pragma interface
26#endif
27
28#ifdef WXPREC
29#include <wx/wxprec.h>
30#else
31#include <wx/wx.h>
32#endif
33
34class WXDLLEXPORT wxSockAddress : public wxObject {
35 DECLARE_ABSTRACT_CLASS(wxSockAddress)
36public:
37 typedef enum { IPV4=1, IPV6=2, UNIX=3 } Addr;
38
39 wxSockAddress() {};
40 virtual ~wxSockAddress() {};
41
42 virtual void Clear() = 0;
43
44 virtual void Build(struct sockaddr*& addr, size_t& len) = 0;
45 virtual void Disassemble(struct sockaddr *addr, size_t len) = 0;
46 virtual int SockAddrLen() = 0;
47
48 virtual int GetFamily() = 0;
49 virtual int Type() = 0;
50};
51
52class WXDLLEXPORT wxIPV4address : public wxSockAddress {
53 DECLARE_DYNAMIC_CLASS(wxIPV4address)
54private:
55 struct sockaddr_in *m_addr;
56public:
57 wxIPV4address();
58 virtual ~wxIPV4address();
59
60 virtual void Clear();
61// const wxSockAddress& operator =(const wxSockAddress& addr);
62
63 virtual bool Hostname(const wxString& name);
64 virtual bool Hostname(unsigned long addr);
65 virtual bool Service(const wxString& name);
66 virtual bool Service(unsigned short port);
67 virtual bool LocalHost();
68
69 wxString Hostname();
70 unsigned short Service();
71
72 void Build(struct sockaddr*& addr, size_t& len);
73 void Disassemble(struct sockaddr *addr, size_t len);
74
75 inline int SockAddrLen();
76 inline int GetFamily();
77 inline int Type() { return wxSockAddress::IPV4; }
78};
79
80#ifdef ENABLE_IPV6
81class WXDLLEXPORT wxIPV6address : public wxSockAddress {
82 DECLARE_DYNAMIC_CLASS(wxIPV6address)
83private:
84 struct sockaddr_in6 *m_addr;
85public:
86 wxIPV6address();
87 ~wxIPV6address();
88
89 void Clear();
90// const wxSockAddress& operator =(const wxSockAddress& addr);
91
92 bool Hostname(const wxString& name);
93 bool Hostname(unsigned char addr[16]);
94 bool Service(const wxString& name);
95 bool Service(unsigned short port);
96 bool LocalHost();
97
98 wxString Hostname() const;
99 unsigned short Service() const;
100
101 void Build(struct sockaddr*& addr, size_t& len);
102 void Disassemble(struct sockaddr *addr, size_t len);
103
104 inline int SockAddrLen();
105 inline int GetFamily();
106 inline int Type() { return wxSockAddress::IPV6; }
107};
108#endif
109
110#ifdef __UNIX__
111#include <sys/un.h>
112
113class WXDLLEXPORT wxUNIXaddress : public wxSockAddress {
114 DECLARE_DYNAMIC_CLASS(wxUNIXaddress)
115private:
116 struct sockaddr_un *m_addr;
117public:
118 wxUNIXaddress();
119 ~wxUNIXaddress();
120
121 void Clear();
122// const wxSockAddress& operator =(const wxSockAddress& addr);
123
124 void Filename(const wxString& name);
125 wxString Filename();
126
127 void Build(struct sockaddr*& addr, size_t& len);
128 void Disassemble(struct sockaddr *addr, size_t len);
129
130 inline int SockAddrLen();
131 inline int GetFamily();
132 inline int Type() { return wxSockAddress::UNIX; }
133};
134#endif
135
136#endif