]> git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/gsockunx.h
really fixed wxMenuBar::Remove (bug 610850): reverted incorrect patch 649599 and...
[wxWidgets.git] / include / wx / unix / gsockunx.h
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockunx.h
4 * Purpose: GSocket Unix 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
24 class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
25 {
26 public:
27 virtual bool OnInit();
28 virtual void OnExit();
29 virtual bool CanUseEventLoop();
30 virtual bool Init_Socket(GSocket *socket);
31 virtual void Destroy_Socket(GSocket *socket);
32 virtual void Install_Callback(GSocket *socket, GSocketEvent event);
33 virtual void Uninstall_Callback(GSocket *socket, GSocketEvent event);
34 virtual void Enable_Events(GSocket *socket);
35 virtual void Disable_Events(GSocket *socket);
36 };
37
38 class GSocket
39 {
40 public:
41 GSocket();
42 virtual ~GSocket();
43 bool IsOk() { return m_ok; }
44 void Close();
45 void Shutdown();
46 GSocketError SetLocal(GAddress *address);
47 GSocketError SetPeer(GAddress *address);
48 GAddress *GetLocal();
49 GAddress *GetPeer();
50 GSocketError SetServer();
51 GSocket *WaitConnection();
52 bool SetReusable();
53 GSocketError Connect(GSocketStream stream);
54 GSocketError SetNonOriented();
55 int Read(char *buffer, int size);
56 int Write(const char *buffer, int size);
57 GSocketEventFlags Select(GSocketEventFlags flags);
58 void SetNonBlocking(bool non_block);
59 void SetTimeout(unsigned long millisec);
60 GSocketError WXDLLIMPEXP_NET GetError();
61 void SetCallback(GSocketEventFlags flags,
62 GSocketCallback callback, char *cdata);
63 void UnsetCallback(GSocketEventFlags flags);
64 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
65 GSocketError SetSockOpt(int level, int optname,
66 const void *optval, int optlen);
67 /* API compatibility functions */
68 static void _GSocket_Detected_Read(GSocket *socket);
69 static void _GSocket_Detected_Write(GSocket *socket);
70 virtual void Detected_Read();
71 virtual void Detected_Write();
72 protected:
73 void Enable(GSocketEvent event);
74 void Disable(GSocketEvent event);
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 bool m_ok;
82 public:
83 /* DFE: We can't protect these data member until the GUI code is updated */
84 /* protected: */
85 int m_fd;
86 GAddress *m_local;
87 GAddress *m_peer;
88 GSocketError m_error;
89
90 bool m_non_blocking;
91 bool m_server;
92 bool m_stream;
93 bool m_establishing;
94 bool m_reusable;
95 unsigned long m_timeout;
96
97 /* Callbacks */
98 GSocketEventFlags m_detected;
99 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
100 char *m_data[GSOCK_MAX_EVENT];
101
102 char *m_gui_dependent;
103
104 };
105
106 #ifdef __cplusplus
107 extern "C" {
108 #endif /* __cplusplus */
109 /* Definition of GAddress */
110 struct _GAddress
111 {
112 struct sockaddr *m_addr;
113 size_t m_len;
114
115 GAddressType m_family;
116 int m_realfamily;
117
118 GSocketError m_error;
119 };
120 #ifdef __cplusplus
121 }
122 #endif /* __cplusplus */
123
124
125 #ifdef __cplusplus
126 extern "C" {
127 #endif /* __cplusplus */
128
129
130 /* GAddress */
131
132 GSocketError _GAddress_translate_from(GAddress *address,
133 struct sockaddr *addr, int len);
134 GSocketError _GAddress_translate_to (GAddress *address,
135 struct sockaddr **addr, int *len);
136 GSocketError _GAddress_Init_INET(GAddress *address);
137 GSocketError _GAddress_Init_UNIX(GAddress *address);
138
139
140 #ifdef __cplusplus
141 }
142 #endif /* __cplusplus */
143
144 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
145
146 #endif /* __GSOCK_UNX_H */