]> git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/gsockunx.h
don't access m_clientDataItemsType directly
[wxWidgets.git] / include / wx / unix / gsockunx.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 Unix 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 class wxGSocketIOHandler;
19
20 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
21
22 #ifndef __GSOCKET_STANDALONE__
23 #include "wx/gsocket.h"
24 #else
25 #include "gsocket.h"
26 #endif
27
28 #include "wx/private/gsocketiohandler.h"
29
30 class GSocketGUIFunctionsTableConcrete : public GSocketGUIFunctionsTable
31 {
32 public:
33 virtual bool OnInit();
34 virtual void OnExit();
35 virtual bool CanUseEventLoop();
36 virtual bool Init_Socket(GSocket *socket);
37 virtual void Destroy_Socket(GSocket *socket);
38 virtual void Install_Callback(GSocket *socket, GSocketEvent event);
39 virtual void Uninstall_Callback(GSocket *socket, GSocketEvent event);
40 virtual void Enable_Events(GSocket *socket);
41 virtual void Disable_Events(GSocket *socket);
42 };
43
44 class GSocket
45 {
46 public:
47 GSocket();
48 virtual ~GSocket();
49 bool IsOk() { return m_ok; }
50 void Close();
51 void Shutdown();
52 GSocketError SetLocal(GAddress *address);
53 GSocketError SetPeer(GAddress *address);
54 GAddress *GetLocal();
55 GAddress *GetPeer();
56 GSocketError SetServer();
57 GSocket *WaitConnection();
58 bool SetReusable();
59 bool SetBroadcast();
60 bool DontDoBind();
61 GSocketError Connect(GSocketStream stream);
62 GSocketError SetNonOriented();
63 int Read(char *buffer, int size);
64 int Write(const char *buffer, int size);
65 GSocketEventFlags Select(GSocketEventFlags flags);
66 void SetNonBlocking(bool non_block);
67 void SetTimeout(unsigned long millisec);
68 GSocketError WXDLLIMPEXP_NET GetError();
69 void SetCallback(GSocketEventFlags flags,
70 GSocketCallback callback, char *cdata);
71 void UnsetCallback(GSocketEventFlags flags);
72 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
73 GSocketError SetSockOpt(int level, int optname,
74 const void *optval, int optlen);
75 // enable or disable notifications
76 void Notify(bool enable);
77 virtual void Detected_Read();
78 virtual void Detected_Write();
79 protected:
80 //enable or disable event callback using gsocket gui callback table
81 void EnableEvents(bool flag = true);
82 void DisableEvents() { EnableEvents(false); }
83 void Enable(GSocketEvent event);
84 void Disable(GSocketEvent event);
85 GSocketError Input_Timeout();
86 GSocketError Output_Timeout();
87 int Recv_Stream(char *buffer, int size);
88 int Recv_Dgram(char *buffer, int size);
89 int Send_Stream(const char *buffer, int size);
90 int Send_Dgram(const char *buffer, int size);
91 bool m_ok;
92 public:
93 /* DFE: We can't protect these data member until the GUI code is updated */
94 /* protected: */
95 int m_fd;
96 wxGSocketIOHandler *m_handler;
97 GAddress *m_local;
98 GAddress *m_peer;
99 GSocketError m_error;
100
101 bool m_non_blocking;
102 bool m_server;
103 bool m_stream;
104 bool m_establishing;
105 bool m_reusable;
106 bool m_broadcast;
107 bool m_dobind;
108 unsigned long m_timeout;
109
110 // true if socket should fire events (use GUI GSocketFunctionsTable)
111 bool m_use_events;
112
113 /* Callbacks */
114 GSocketEventFlags m_detected;
115 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
116 char *m_data[GSOCK_MAX_EVENT];
117
118 char *m_gui_dependent;
119
120 };
121
122 #ifdef __cplusplus
123 extern "C" {
124 #endif /* __cplusplus */
125 /* Definition of GAddress */
126 struct _GAddress
127 {
128 struct sockaddr *m_addr;
129 size_t m_len;
130
131 GAddressType m_family;
132 int m_realfamily;
133
134 GSocketError m_error;
135 };
136 #ifdef __cplusplus
137 }
138 #endif /* __cplusplus */
139
140
141 #ifdef __cplusplus
142 extern "C" {
143 #endif /* __cplusplus */
144
145
146 /* GAddress */
147
148 GSocketError _GAddress_translate_from(GAddress *address,
149 struct sockaddr *addr, int len);
150 GSocketError _GAddress_translate_to (GAddress *address,
151 struct sockaddr **addr, int *len);
152 GSocketError _GAddress_Init_INET(GAddress *address);
153 GSocketError _GAddress_Init_UNIX(GAddress *address);
154
155
156 #ifdef __cplusplus
157 }
158 #endif /* __cplusplus */
159
160 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
161
162 #endif /* __GSOCK_UNX_H */