]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/socket.cpp
Fix memory leaks in wxAutomationObject::Invoke().
[wxWidgets.git] / src / common / socket.cpp
index 64803df7a4f527d76a9bfc4c280c64ed774b1dbd..0d619a77c2f239f7b83cf12088cc0fc98d10f8f6 100644 (file)
@@ -1297,17 +1297,31 @@ wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags,
         exceptfds;                      // always want to know about errors
 
     if ( flags & wxSOCKET_INPUT_FLAG )
-    {
         preadfds = &readfds;
+
+    if ( flags & wxSOCKET_OUTPUT_FLAG )
+        pwritefds = &writefds;
+
+    // When using non-blocking connect() the client socket becomes connected
+    // (successfully or not) when it becomes writable but when using
+    // non-blocking accept() the server socket becomes connected when it
+    // becomes readable.
+    if ( flags & wxSOCKET_CONNECTION_FLAG )
+    {
+        if ( m_server )
+            preadfds = &readfds;
+        else
+            pwritefds = &writefds;
+    }
+
+    if ( preadfds )
+    {
         wxFD_ZERO(preadfds);
         wxFD_SET(m_fd, preadfds);
     }
 
-    // when using non-blocking connect() the socket becomes connected
-    // (successfully or not) when it becomes writable
-    if ( flags & (wxSOCKET_OUTPUT_FLAG | wxSOCKET_CONNECTION_FLAG) )
+    if ( pwritefds )
     {
-        pwritefds = &writefds;
         wxFD_ZERO(pwritefds);
         wxFD_SET(m_fd, pwritefds);
     }
@@ -1800,7 +1814,11 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr,
         return;
     }
 
-    wxLogTrace( wxTRACE_Socket, wxT("wxSocketServer on fd %d"), m_impl->m_fd );
+    // Notice that we need a cast as SOCKET is 64 bit under Win64 and that the
+    // cast is safe because a SOCKET is a handle and so limited to 32 (or,
+    // actually, even 24) bit values anyhow.
+    wxLogTrace( wxTRACE_Socket, wxT("wxSocketServer on fd %u"),
+                static_cast<unsigned>(m_impl->m_fd) );
 }
 
 // --------------------------------------------------------------------------
@@ -2097,7 +2115,7 @@ wxFORCE_LINK_MODULE( socketiohandler )
 #endif
 
 // same for ManagerSetter in the MSW file
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
     wxFORCE_LINK_MODULE( mswsocket )
 #endif