]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/gsockmac.h
wxHelpController now wxCHMHelpController on Windows
[wxWidgets.git] / include / wx / mac / carbon / gsockmac.h
CommitLineData
8cf73271
SC
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
5b2693a7
SC
24#ifndef OTUNIXERRORS
25
c5602b4a
DE
26#include <MacHeaders.c>
27#define OTUNIXERRORS 1
85f70304
SC
28// we get a conflict in OT headers otherwise :
29#undef EDEADLK
c5602b4a
DE
30#include <OpenTransport.h>
31#include <OpenTransportProviders.h>
32#include <OpenTptInternet.h>
8cf73271 33
5b2693a7
SC
34#endif
35
8cf73271 36/* Definition of GSocket */
c5602b4a 37class GSocket
8cf73271 38{
c5602b4a
DE
39public:
40 GSocket();
41 ~GSocket();
fe942d6f 42 bool IsOk() { return m_ok; }
c5602b4a
DE
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();
948c96ef 51 bool SetReusable() { return false; }
c5602b4a
DE
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);
948c96ef 57 void SetNonBlocking(bool non_block);
c5602b4a
DE
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
69protected:
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
85public:
8cf73271
SC
86 wxMacNotifierTableRef m_mac_events ;
87 EndpointRef m_endpoint;
88 GAddress *m_local;
89 GAddress *m_peer;
90 GSocketError m_error;
91
948c96ef
DE
92 bool m_non_blocking;
93 bool m_server;
94 bool m_stream;
95 bool m_oriented;
8cf73271
SC
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];
948c96ef 102 bool m_takesEvents ;
8cf73271
SC
103};
104
c5602b4a 105
c5602b4a
DE
106#ifdef __cplusplus
107extern "C" {
108#endif /* __cplusplus */
109
8cf73271
SC
110/* Definition of GAddress */
111
112struct _GAddress
113{
114 UInt32 m_host ;
115 UInt16 m_port ;
116 GAddressType m_family;
117 GSocketError m_error;
118};
119
8cf73271
SC
120/* Callbacks */
121
8cf73271
SC
122void _GSocket_Internal_Proc(unsigned long e , void* data ) ;
123
124/* GAddress */
125
126GSocketError _GAddress_translate_from(GAddress *address,
127 InetAddress *addr );
128GSocketError _GAddress_translate_to(GAddress *address,
129 InetAddress *addr);
130
131GSocketError _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 */