]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/socket.cpp
fixing osx_carbon
[wxWidgets.git] / src / common / socket.cpp
index c0c35df4e2e16bbfcf1e80a2cd0b6496a663a675..36a9dc1090f35f9f9d34eb5e3ac5a4704bcde5d3 100644 (file)
@@ -980,7 +980,11 @@ wxUint32 wxSocketBase::DoRead(void* buffer_, wxUint32 nbytes)
             {
                 // if we don't want to wait, just return immediately
                 if ( m_flags & wxSOCKET_NOWAIT )
+                {
+                    // this shouldn't be counted as an error in this case
+                    SetError(wxSOCKET_NOERROR);
                     break;
+                }
 
                 // otherwise wait until the socket becomes ready for reading or
                 // an error occurs on it
@@ -1293,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);
     }