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