]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/gsockmac.h
removed duplicate entries for UTF-16/32 (which are aliases for either LE or BE varian...
[wxWidgets.git] / include / wx / mac / carbon / gsockmac.h
CommitLineData
8cf73271 1/* -------------------------------------------------------------------------
99d80019
JS
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$
8cf73271
SC
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
5b2693a7
SC
26#ifndef OTUNIXERRORS
27
c5602b4a
DE
28#include <MacHeaders.c>
29#define OTUNIXERRORS 1
85f70304
SC
30// we get a conflict in OT headers otherwise :
31#undef EDEADLK
c5602b4a
DE
32#include <OpenTransport.h>
33#include <OpenTransportProviders.h>
34#include <OpenTptInternet.h>
8cf73271 35
5b2693a7
SC
36#endif
37
8cf73271 38/* Definition of GSocket */
c5602b4a 39class GSocket
8cf73271 40{
c5602b4a
DE
41public:
42 GSocket();
43 ~GSocket();
fe942d6f 44 bool IsOk() { return m_ok; }
c5602b4a
DE
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();
948c96ef 53 bool SetReusable() { return false; }
c5602b4a
DE
54 GSocketError SetNonOriented();
55 GSocketError Connect(GSocketStream stream);
56 int Read(char *buffer, int size);
57 int Write(const char *buffer, int size);
58 GSocketEventFlags Select(GSocketEventFlags flags);
948c96ef 59 void SetNonBlocking(bool non_block);
c5602b4a
DE
60 void SetTimeout(unsigned long millisec);
61 GSocketError WXDLLIMPEXP_NET GetError();
62 void SetCallback(GSocketEventFlags flags,
63 GSocketCallback callback, char *cdata);
64 void UnsetCallback(GSocketEventFlags flags);
65 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen)
66 { return GSOCK_INVOP; }
67 GSocketError SetSockOpt(int level, int optname,
68 const void *optval, int optlen)
69 { return GSOCK_INVOP; }
70
71protected:
72 bool m_ok;
73
74 /* Input / Output */
75 GSocketError Input_Timeout();
76 GSocketError Output_Timeout();
77 int Recv_Stream(char *buffer, int size);
78 int Recv_Dgram(char *buffer, int size);
79 int Send_Stream(const char *buffer, int size);
80 int Send_Dgram(const char *buffer, int size);
81
82 /* Callbacks */
83 void Enable_Events();
84 void Disable_Events();
85
86// TODO: Make these protected
87public:
8cf73271
SC
88 wxMacNotifierTableRef m_mac_events ;
89 EndpointRef m_endpoint;
90 GAddress *m_local;
91 GAddress *m_peer;
92 GSocketError m_error;
93
948c96ef
DE
94 bool m_non_blocking;
95 bool m_server;
96 bool m_stream;
97 bool m_oriented;
8cf73271
SC
98 unsigned long m_timeout;
99
100 /* Callbacks */
101 GSocketEventFlags m_detected;
102 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
103 char *m_data[GSOCK_MAX_EVENT];
948c96ef 104 bool m_takesEvents ;
8cf73271
SC
105};
106
c5602b4a 107
c5602b4a
DE
108#ifdef __cplusplus
109extern "C" {
110#endif /* __cplusplus */
111
8cf73271
SC
112/* Definition of GAddress */
113
114struct _GAddress
115{
116 UInt32 m_host ;
117 UInt16 m_port ;
118 GAddressType m_family;
119 GSocketError m_error;
120};
121
8cf73271
SC
122/* Callbacks */
123
8cf73271
SC
124void _GSocket_Internal_Proc(unsigned long e , void* data ) ;
125
126/* GAddress */
127
128GSocketError _GAddress_translate_from(GAddress *address,
129 InetAddress *addr );
130GSocketError _GAddress_translate_to(GAddress *address,
131 InetAddress *addr);
132
133GSocketError _GAddress_Init_INET(GAddress *address);
134
135#ifdef __cplusplus
136}
137#endif /* __cplusplus */
138
139#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
140
141#endif /* __GSOCK_UNX_H */