class WXDLLIMPEXP_NET wxSocketBase : public wxObject
 {
-  DECLARE_CLASS(wxSocketBase)
-
 public:
 
   // Public interface
   void         *m_clientData;       // client data for events
   bool          m_notify;           // notify events to users?
   wxSocketEventFlags  m_eventmask;  // which events to notify?
+  wxSocketEventFlags  m_eventsgot;  // collects events received in OnRequest()
 
   // the initialization count, GSocket is initialized if > 0
   static size_t m_countInit;
 
   DECLARE_NO_COPY_CLASS(wxSocketBase)
+  DECLARE_CLASS(wxSocketBase)
 };
 
 
 
     m_handler      = NULL;
     m_clientData   = NULL;
     m_notify       = false;
-    m_eventmask    = 0;
+    m_eventmask    =
+    m_eventsgot    = 0;
 
     if ( !IsInitialized() )
     {
 
 void wxSocketBase::OnRequest(wxSocketNotify notification)
 {
-    switch(notification)
+    switch ( notification )
     {
         case wxSOCKET_CONNECTION:
             m_establishing = false;
             return;
     }
 
-    // Schedule the event
-
     wxSocketEventFlags flag = 0;
-    wxUnusedVar(flag);
-    switch (notification)
+    switch ( notification )
     {
-        case wxSOCKET_INPUT:      flag = wxSOCKET_INPUT_FLAG; break;
-        case wxSOCKET_OUTPUT:     flag = wxSOCKET_OUTPUT_FLAG; break;
-        case wxSOCKET_CONNECTION: flag = wxSOCKET_CONNECTION_FLAG; break;
-        case wxSOCKET_LOST:       flag = wxSOCKET_LOST_FLAG; break;
+        case wxSOCKET_INPUT:
+            flag = wxSOCKET_INPUT_FLAG;
+            break;
+
+        case wxSOCKET_OUTPUT:
+            flag = wxSOCKET_OUTPUT_FLAG;
+            break;
+
+        case wxSOCKET_CONNECTION:
+            flag = wxSOCKET_CONNECTION_FLAG;
+            break;
+
+        case wxSOCKET_LOST:
+            flag = wxSOCKET_LOST_FLAG;
+            break;
+
         default:
-                               wxLogWarning(_("wxSocket: unknown event!."));
-                               return;
+            wxFAIL_MSG( "unknown wxSocket notification" );
     }
 
-    if (((m_eventmask & flag) == flag) && m_notify)
+    // remember the events which were generated for this socket, we're going to
+    // use this in DoWait()
+    m_eventsgot |= flag;
+
+    // send the wx event if enabled and we're interested in it
+    if ( m_notify && (m_eventmask & flag) && m_handler )
     {
-        if (m_handler)
-        {
-            wxSocketEvent event(m_id);
-            event.m_event      = notification;
-            event.m_clientData = m_clientData;
-            event.SetEventObject(this);
+        wxSocketEvent event(m_id);
+        event.m_event      = notification;
+        event.m_clientData = m_clientData;
+        event.SetEventObject(this);
 
-            m_handler->AddPendingEvent(event);
-        }
+        m_handler->AddPendingEvent(event);
     }
 }