]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/gsockmac.h
wxHelpController now wxCHMHelpController on Windows
[wxWidgets.git] / include / wx / mac / carbon / gsockmac.h
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockunx.h
4 * Purpose: GSocket Macintosh header
5 * CVSID: $Id$
6 * -------------------------------------------------------------------------
7 */
8
9 #ifndef __GSOCK_UNX_H
10 #define __GSOCK_UNX_H
11
12 #ifndef __GSOCKET_STANDALONE__
13 #include "wx/setup.h"
14 #endif
15
16 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
17
18 #ifndef __GSOCKET_STANDALONE__
19 #include "wx/gsocket.h"
20 #else
21 #include "gsocket.h"
22 #endif
23
24 #ifndef OTUNIXERRORS
25
26 #include <MacHeaders.c>
27 #define OTUNIXERRORS 1
28 // we get a conflict in OT headers otherwise :
29 #undef EDEADLK
30 #include <OpenTransport.h>
31 #include <OpenTransportProviders.h>
32 #include <OpenTptInternet.h>
33
34 #endif
35
36 /* Definition of GSocket */
37 class GSocket
38 {
39 public:
40 GSocket();
41 ~GSocket();
42 bool IsOk() { return m_ok; }
43
44 void Shutdown();
45 GSocketError SetLocal(GAddress *address);
46 GSocketError SetPeer(GAddress *address);
47 GAddress *GetLocal();
48 GAddress *GetPeer();
49 GSocketError SetServer();
50 GSocket *WaitConnection();
51 bool SetReusable() { return false; }
52 GSocketError SetNonOriented();
53 GSocketError Connect(GSocketStream stream);
54 int Read(char *buffer, int size);
55 int Write(const char *buffer, int size);
56 GSocketEventFlags Select(GSocketEventFlags flags);
57 void SetNonBlocking(bool non_block);
58 void SetTimeout(unsigned long millisec);
59 GSocketError WXDLLIMPEXP_NET GetError();
60 void SetCallback(GSocketEventFlags flags,
61 GSocketCallback callback, char *cdata);
62 void UnsetCallback(GSocketEventFlags flags);
63 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen)
64 { return GSOCK_INVOP; }
65 GSocketError SetSockOpt(int level, int optname,
66 const void *optval, int optlen)
67 { return GSOCK_INVOP; }
68
69 protected:
70 bool m_ok;
71
72 /* Input / Output */
73 GSocketError Input_Timeout();
74 GSocketError Output_Timeout();
75 int Recv_Stream(char *buffer, int size);
76 int Recv_Dgram(char *buffer, int size);
77 int Send_Stream(const char *buffer, int size);
78 int Send_Dgram(const char *buffer, int size);
79
80 /* Callbacks */
81 void Enable_Events();
82 void Disable_Events();
83
84 // TODO: Make these protected
85 public:
86 wxMacNotifierTableRef m_mac_events ;
87 EndpointRef m_endpoint;
88 GAddress *m_local;
89 GAddress *m_peer;
90 GSocketError m_error;
91
92 bool m_non_blocking;
93 bool m_server;
94 bool m_stream;
95 bool m_oriented;
96 unsigned long m_timeout;
97
98 /* Callbacks */
99 GSocketEventFlags m_detected;
100 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
101 char *m_data[GSOCK_MAX_EVENT];
102 bool m_takesEvents ;
103 };
104
105
106 #ifdef __cplusplus
107 extern "C" {
108 #endif /* __cplusplus */
109
110 /* Definition of GAddress */
111
112 struct _GAddress
113 {
114 UInt32 m_host ;
115 UInt16 m_port ;
116 GAddressType m_family;
117 GSocketError m_error;
118 };
119
120 /* Callbacks */
121
122 void _GSocket_Internal_Proc(unsigned long e , void* data ) ;
123
124 /* GAddress */
125
126 GSocketError _GAddress_translate_from(GAddress *address,
127 InetAddress *addr );
128 GSocketError _GAddress_translate_to(GAddress *address,
129 InetAddress *addr);
130
131 GSocketError _GAddress_Init_INET(GAddress *address);
132
133 #ifdef __cplusplus
134 }
135 #endif /* __cplusplus */
136
137 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
138
139 #endif /* __GSOCK_UNX_H */