]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/socket.cpp
MSW: Grouped all MSVC #pragma disable
[wxWidgets.git] / src / common / socket.cpp
index 0f13466c0c327c85c8f3059586a5744a1f76e2a0..5036742c4d37d24dad94859e4445bcb972511dd5 100644 (file)
@@ -244,8 +244,13 @@ wxUint32 wxSocketBase::_Read(void* buffer, wxUint32 nbytes)
   nbytes -= total;
   buffer  = (char *)buffer + total;
 
-  // If the socket is invalid or we got all the data, return now
-  if (!m_socket || !nbytes)
+  // Return now in one of the following cases:
+  // - the socket is invalid,
+  // - we got all the data,
+  // - we got *some* data and we are not using wxSOCKET_WAITALL.
+  if ( !m_socket ||
+       !nbytes ||
+       ((total != 0) && !(m_flags & wxSOCKET_WAITALL)) )
     return total;
 
   // Possible combinations (they are checked in this order)
@@ -893,13 +898,16 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
 
   // Schedule the event
 
-  wxSocketEventFlags flag = -1;
+  wxSocketEventFlags flag = 0;
   switch (notification)
   {
     case GSOCK_INPUT:      flag = GSOCK_INPUT_FLAG; break;
     case GSOCK_OUTPUT:     flag = GSOCK_OUTPUT_FLAG; break;
     case GSOCK_CONNECTION: flag = GSOCK_CONNECTION_FLAG; break;
     case GSOCK_LOST:       flag = GSOCK_LOST_FLAG; break;
+    default:
+      wxLogWarning( _("wxSocket: unknown event!."));
+      return;
   }
 
   if (((m_eventmask & flag) == flag) && m_notify)