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