]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/unix/gsockunx.h
compilation fix for gcc<3.4
[wxWidgets.git] / include / wx / unix / gsockunx.h
... / ...
CommitLineData
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#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
26class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
27{
28public:
29 virtual bool OnInit();
30 virtual void OnExit();
31 virtual bool CanUseEventLoop();
32 virtual bool Init_Socket(GSocket *socket);
33 virtual void Destroy_Socket(GSocket *socket);
34 virtual void Install_Callback(GSocket *socket, GSocketEvent event);
35 virtual void Uninstall_Callback(GSocket *socket, GSocketEvent event);
36 virtual void Enable_Events(GSocket *socket);
37 virtual void Disable_Events(GSocket *socket);
38};
39
40class GSocket
41{
42public:
43 GSocket();
44 virtual ~GSocket();
45 bool IsOk() { return m_ok; }
46 void Close();
47 void Shutdown();
48 GSocketError SetLocal(GAddress *address);
49 GSocketError SetPeer(GAddress *address);
50 GAddress *GetLocal();
51 GAddress *GetPeer();
52 GSocketError SetServer();
53 GSocket *WaitConnection();
54 bool SetReusable();
55 bool SetBroadcast();
56 bool DontDoBind();
57 GSocketError Connect(GSocketStream stream);
58 GSocketError SetNonOriented();
59 int Read(char *buffer, int size);
60 int Write(const char *buffer, int size);
61 GSocketEventFlags Select(GSocketEventFlags flags);
62 void SetNonBlocking(bool non_block);
63 void SetTimeout(unsigned long millisec);
64 GSocketError WXDLLIMPEXP_NET GetError();
65 void SetCallback(GSocketEventFlags flags,
66 GSocketCallback callback, char *cdata);
67 void UnsetCallback(GSocketEventFlags flags);
68 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
69 GSocketError SetSockOpt(int level, int optname,
70 const void *optval, int optlen);
71 virtual void Detected_Read();
72 virtual void Detected_Write();
73protected:
74 void Enable(GSocketEvent event);
75 void Disable(GSocketEvent event);
76 GSocketError Input_Timeout();
77 GSocketError Output_Timeout();
78 int Recv_Stream(char *buffer, int size);
79 int Recv_Dgram(char *buffer, int size);
80 int Send_Stream(const char *buffer, int size);
81 int Send_Dgram(const char *buffer, int size);
82 bool m_ok;
83public:
84 /* DFE: We can't protect these data member until the GUI code is updated */
85 /* protected: */
86 int m_fd;
87 GAddress *m_local;
88 GAddress *m_peer;
89 GSocketError m_error;
90
91 bool m_non_blocking;
92 bool m_server;
93 bool m_stream;
94 bool m_establishing;
95 bool m_reusable;
96 bool m_broadcast;
97 bool m_dobind;
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];
104
105 char *m_gui_dependent;
106
107};
108
109#ifdef __cplusplus
110extern "C" {
111#endif /* __cplusplus */
112/* Definition of GAddress */
113struct _GAddress
114{
115 struct sockaddr *m_addr;
116 size_t m_len;
117
118 GAddressType m_family;
119 int m_realfamily;
120
121 GSocketError m_error;
122};
123#ifdef __cplusplus
124}
125#endif /* __cplusplus */
126
127
128#ifdef __cplusplus
129extern "C" {
130#endif /* __cplusplus */
131
132
133/* GAddress */
134
135GSocketError _GAddress_translate_from(GAddress *address,
136 struct sockaddr *addr, int len);
137GSocketError _GAddress_translate_to (GAddress *address,
138 struct sockaddr **addr, int *len);
139GSocketError _GAddress_Init_INET(GAddress *address);
140GSocketError _GAddress_Init_UNIX(GAddress *address);
141
142
143#ifdef __cplusplus
144}
145#endif /* __cplusplus */
146
147#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
148
149#endif /* __GSOCK_UNX_H */