1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket Unix header
6 * -------------------------------------------------------------------------
12 #ifndef __GSOCKET_STANDALONE__
16 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
18 #ifndef __GSOCKET_STANDALONE__
19 #include "wx/gsocket.h"
32 class GSocketGUIFunctionsTableConcrete
: public GSocketGUIFunctionsTable
35 virtual bool OnInit();
36 virtual void OnExit();
37 virtual bool CanUseEventLoop();
38 virtual bool Init_Socket(GSocket
*socket
);
39 virtual void Destroy_Socket(GSocket
*socket
);
40 virtual void Install_Callback(GSocket
*socket
, GSocketEvent event
);
41 virtual void Uninstall_Callback(GSocket
*socket
, GSocketEvent event
);
42 virtual void Enable_Events(GSocket
*socket
);
43 virtual void Disable_Events(GSocket
*socket
);
51 bool IsOk() { return m_ok
; }
54 GSocketError
SetLocal(GAddress
*address
);
55 GSocketError
SetPeer(GAddress
*address
);
58 GSocketError
SetServer();
59 GSocket
*WaitConnection();
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(int 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 /* API compatibility functions */
76 static void _GSocket_Detected_Read(GSocket
*socket
);
77 static void _GSocket_Detected_Write(GSocket
*socket
);
78 virtual void Detected_Read();
79 virtual void Detected_Write();
81 void Enable(GSocketEvent event
);
82 void Disable(GSocketEvent event
);
83 GSocketError
Input_Timeout();
84 GSocketError
Output_Timeout();
85 int Recv_Stream(char *buffer
, int size
);
86 int Recv_Dgram(char *buffer
, int size
);
87 int Send_Stream(const char *buffer
, int size
);
88 int Send_Dgram(const char *buffer
, int size
);
91 /* DFE: We can't protect these data member until the GUI code is updated */
103 unsigned long m_timeout
;
106 GSocketEventFlags m_detected
;
107 GSocketCallback m_cbacks
[GSOCK_MAX_EVENT
];
108 char *m_data
[GSOCK_MAX_EVENT
];
110 char *m_gui_dependent
;
116 #endif /* __cplusplus */
117 /* Definition of GAddress */
120 struct sockaddr
*m_addr
;
123 GAddressType m_family
;
126 GSocketError m_error
;
130 #endif /* __cplusplus */
132 /* Compatibility methods to support old C API (from gsocket.h) */
133 inline void GSocket_Shutdown(GSocket
*socket
)
134 { socket
->Shutdown(); }
135 inline GSocketError
GSocket_SetLocal(GSocket
*socket
, GAddress
*address
)
136 { return socket
->SetLocal(address
); }
137 inline GSocketError
GSocket_SetPeer(GSocket
*socket
, GAddress
*address
)
138 { return socket
->SetPeer(address
); }
139 inline GAddress
*GSocket_GetLocal(GSocket
*socket
)
140 { return socket
->GetLocal(); }
141 inline GAddress
*GSocket_GetPeer(GSocket
*socket
)
142 { return socket
->GetPeer(); }
143 inline GSocketError
GSocket_SetServer(GSocket
*socket
)
144 { return socket
->SetServer(); }
145 inline GSocket
*GSocket_WaitConnection(GSocket
*socket
)
146 { return socket
->WaitConnection(); }
147 inline int GSocket_SetReusable(GSocket
*socket
)
148 { return socket
->SetReusable(); }
149 inline GSocketError
GSocket_Connect(GSocket
*socket
, GSocketStream stream
)
150 { return socket
->Connect(stream
); }
151 inline GSocketError
GSocket_SetNonOriented(GSocket
*socket
)
152 { return socket
->SetNonOriented(); }
153 inline int GSocket_Read(GSocket
*socket
, char *buffer
, int size
)
154 { return socket
->Read(buffer
,size
); }
155 inline int GSocket_Write(GSocket
*socket
, const char *buffer
, int size
)
156 { return socket
->Write(buffer
,size
); }
157 inline GSocketEventFlags
GSocket_Select(GSocket
*socket
, GSocketEventFlags flags
)
158 { return socket
->Select(flags
); }
159 inline void GSocket_SetNonBlocking(GSocket
*socket
, int non_block
)
160 { socket
->SetNonBlocking(non_block
); }
161 inline void GSocket_SetTimeout(GSocket
*socket
, unsigned long millisec
)
162 { socket
->SetTimeout(millisec
); }
163 inline GSocketError
GSocket_GetError(GSocket
*socket
)
164 { return socket
->GetError(); }
165 inline void GSocket_SetCallback(GSocket
*socket
, GSocketEventFlags flags
,
166 GSocketCallback fallback
, char *cdata
)
167 { socket
->SetCallback(flags
,fallback
,cdata
); }
168 inline void GSocket_UnsetCallback(GSocket
*socket
, GSocketEventFlags flags
)
169 { socket
->UnsetCallback(flags
); }
170 inline GSocketError
GSocket_GetSockOpt(GSocket
*socket
, int level
, int optname
,
171 void *optval
, int *optlen
)
172 { return socket
->GetSockOpt(level
,optname
,optval
,optlen
); }
173 inline GSocketError
GSocket_SetSockOpt(GSocket
*socket
, int level
, int optname
,
174 const void *optval
, int optlen
)
175 { return socket
->SetSockOpt(level
,optname
,optval
,optlen
); }
176 inline void GSocket_destroy(GSocket
*socket
)
182 #endif /* __cplusplus */
187 GSocketError
_GAddress_translate_from(GAddress
*address
,
188 struct sockaddr
*addr
, int len
);
189 GSocketError
_GAddress_translate_to (GAddress
*address
,
190 struct sockaddr
**addr
, int *len
);
191 GSocketError
_GAddress_Init_INET(GAddress
*address
);
192 GSocketError
_GAddress_Init_UNIX(GAddress
*address
);
197 #endif /* __cplusplus */
199 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
201 #endif /* __GSOCK_UNX_H */