- if (m_cbkon && old_needed_req != flags)
- SetupCallbacks();
-}
-
-void wxSocketBase::SetupCallbacks()
-{
- if (m_fd == INVALID_SOCKET || !m_handler || (m_flags & SPEED))
- return;
-
-#if defined(__WXMOTIF__) || defined(__WXXT__) || defined(__WXGTK__)
- if (m_cbkon)
- DestroyCallbacks();
- if (m_neededreq & (REQ_ACCEPT | REQ_READ | REQ_LOST)) {
-#ifdef __WXGTK__
- m_internal->sock_inputid = gdk_input_add(m_fd, GDK_INPUT_READ,
- wx_socket_read, (gpointer)this);
-#else
- m_internal->sock_inputid = XtAppAddInput (wxAPP_CONTEXT, m_fd,
- (XtPointer *) XtInputReadMask,
- (XtInputCallbackProc) wx_socket_read,
- (XtPointer) this);
-#endif
- }
- if (m_neededreq & (REQ_CONNECT | REQ_WRITE)) {
-#ifdef __WXGTK__
- m_internal->sock_inputid = gdk_input_add(m_fd, GDK_INPUT_WRITE,
- wx_socket_write, (gpointer)this);
-#else
- m_internal->sock_outputid = XtAppAddInput (wxAPP_CONTEXT, m_fd,
- (XtPointer *) XtInputWriteMask,
- (XtInputCallbackProc) wx_socket_write,
- (XtPointer) this);
-#endif
- }
-#endif
-#ifdef __WINDOWS__
- WORD mask = 0;
-
- if (m_neededreq & REQ_READ)
- mask |= FD_READ;
- if (m_neededreq & REQ_WRITE)
- mask |= FD_WRITE;
- if (m_neededreq & REQ_LOST)
- mask |= FD_CLOSE;
- if (m_neededreq & REQ_ACCEPT)
- mask |= FD_ACCEPT;
- if (m_neededreq & REQ_CONNECT)
- mask |= FD_CONNECT;
-
- if (!m_internal->my_msg)
- m_internal->my_msg = m_handler->NewMessage(this);
- WSAAsyncSelect(m_fd, m_handler->GetHWND(), m_internal->my_msg, mask);
-#endif
- m_cbkon = TRUE;
- m_processing = FALSE;
-}
-
-void wxSocketBase::DestroyCallbacks()
-{
- if (!m_cbkon || !m_handler)
- return;
- m_cbkon = FALSE;
- m_processing = FALSE;
-#if defined(__WXMOTIF__) || defined(__WXXT__)
- if (m_internal->sock_inputid > 0)
- XtRemoveInput(m_internal->sock_inputid);
- m_internal->sock_inputid = 0;
- if (m_internal->sock_outputid > 0)
- XtRemoveInput(m_internal->sock_outputid);
- m_internal->sock_outputid = 0;
-#endif
-#ifdef __WXGTK__
- if (m_internal->sock_inputid > 0)
- gdk_input_remove(m_internal->sock_inputid);
- m_internal->sock_inputid = 0;
- if (m_internal->sock_outputid > 0)
- gdk_input_remove(m_internal->sock_outputid);
- m_internal->sock_outputid = 0;
-#endif
-#ifdef __WINDOWS__
- WSAAsyncSelect(m_fd, m_handler->GetHWND(), 0, 0);
-#endif