+// A version of GSocketManager which uses FDs for socket IO
+//
+// This class uses GSocket::m_gui_dependent field to store the 2 (for input and
+// output) FDs associated with the socket.
+class GSocketFDBasedManager : public GSocketManager
+{
+public:
+ // no special initialization/cleanup needed when using FDs
+ virtual bool OnInit() { return true; }
+ virtual void OnExit() { }
+
+ // allocate/free the storage we need
+ virtual bool Init_Socket(GSocket *socket)
+ {
+ socket->m_gui_dependent = malloc(sizeof(int)*2);
+ int * const fds = wx_static_cast(int *, socket->m_gui_dependent);
+
+ fds[0] = -1;
+ fds[1] = -1;
+
+ return true;
+ }
+ virtual void Destroy_Socket(GSocket *socket)
+ {
+ free(socket->m_gui_dependent);
+ }
+
+ virtual void Enable_Events(GSocket *socket)
+ {
+ Install_Callback(socket, GSOCK_INPUT);
+ Install_Callback(socket, GSOCK_OUTPUT);
+ }
+ virtual void Disable_Events(GSocket *socket)
+ {
+ Uninstall_Callback(socket, GSOCK_INPUT);
+ Uninstall_Callback(socket, GSOCK_OUTPUT);
+ }