]> git.saurik.com Git - wxWidgets.git/commitdiff
remove wxSOCKET_MAX_EVENT, it is not really necessary and results in gcc warnings...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 30 Dec 2008 00:11:04 +0000 (00:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 30 Dec 2008 00:11:04 +0000 (00:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/private/socket.h
include/wx/socket.h
include/wx/unix/private/sockunix.h
src/msw/sockmsw.cpp
src/osx/core/sockosx.cpp

index e736a83dbd5ff0116373f66fc94bade1a8731b2e..0bc2f3b8100254447ebc9f6d58d0a86cb5c113f4 100644 (file)
@@ -144,10 +144,15 @@ public:
     // that both BSD and Winsock implementations actually use socket->m_server
     // value to determine what exactly should be monitored so it needs to be
     // set before calling these functions)
+    //
+    // the default event value is used just for the convenience of wxMSW
+    // implementation which doesn't use this parameter anyhow, it doesn't make
+    // sense to pass wxSOCKET_LOST for the Unix implementation which does use
+    // this parameter
     virtual void Install_Callback(wxSocketImpl *socket,
-                                  wxSocketNotify event = wxSOCKET_MAX_EVENT) = 0;
+                                  wxSocketNotify event = wxSOCKET_LOST) = 0;
     virtual void Uninstall_Callback(wxSocketImpl *socket,
-                                    wxSocketNotify event = wxSOCKET_MAX_EVENT) = 0;
+                                    wxSocketNotify event = wxSOCKET_LOST) = 0;
 
     virtual ~wxSocketManager() { }
 
index 2cb0467ce5a38d0bc83b63d482fc62764a5aefc3..88291e6ac2c0fd06ebb026d5567035b478c88127 100644 (file)
@@ -39,8 +39,7 @@ enum wxSocketNotify
     wxSOCKET_INPUT,
     wxSOCKET_OUTPUT,
     wxSOCKET_CONNECTION,
-    wxSOCKET_LOST,
-    wxSOCKET_MAX_EVENT
+    wxSOCKET_LOST
 };
 
 enum
index 4ff2164b44912c16241d3093635d084b133d141d..5e910a4cf1e734898fb19dd089e193af31d3595e 100644 (file)
@@ -109,11 +109,12 @@ protected:
         switch ( event )
         {
             default:
-                wxFAIL_MSG( "unexpected socket event" );
-                // fall through
+                wxFAIL_MSG( "unknown socket event" );
+                return FD_INPUT; // we must return something
 
             case wxSOCKET_LOST:
-                // fall through
+                wxFAIL_MSG( "unexpected socket event" );
+                return FD_INPUT; // as above
 
             case wxSOCKET_INPUT:
                 return FD_INPUT;
@@ -122,7 +123,12 @@ protected:
                 return FD_OUTPUT;
 
             case wxSOCKET_CONNECTION:
-                // FIXME: explain this?
+                // for server sockets we're interested in events indicating
+                // that a new connection is pending, i.e. that accept() will
+                // succeed and this is indicated by socket becoming ready for
+                // reading, while for the other ones we're interested in the
+                // completion of non-blocking connect() which is indicated by
+                // the socket becoming ready for writing
                 return socket->IsServer() ? FD_INPUT : FD_OUTPUT;
         }
     }
index 33ce4ab540fc43388e06e9b74b4a09dabcba4419..ebabf7d085851d2cc99b3e4fd69e1f7f964d4860 100644 (file)
@@ -179,8 +179,10 @@ public:
     {
         return new wxSocketImplMSW(wxsocket);
     }
-    virtual void Install_Callback(wxSocketImpl *socket, wxSocketNotify event);
-    virtual void Uninstall_Callback(wxSocketImpl *socket, wxSocketNotify event);
+    virtual void Install_Callback(wxSocketImpl *socket,
+                                  wxSocketNotify event = wxSOCKET_LOST);
+    virtual void Uninstall_Callback(wxSocketImpl *socket,
+                                    wxSocketNotify event = wxSOCKET_LOST);
 
 private:
     static wxDynamicLibrary gs_wsock32dll;
@@ -402,7 +404,7 @@ void wxSocketMSWManager::Install_Callback(wxSocketImpl *socket_,
  *  Disable event notifications (used when shutting down the socket)
  */
 void wxSocketMSWManager::Uninstall_Callback(wxSocketImpl *socket_,
-                                           wxSocketNotify WXUNUSED(event))
+                                            wxSocketNotify WXUNUSED(event))
 {
     wxSocketImplMSW * const socket = static_cast<wxSocketImplMSW *>(socket_);
 
@@ -442,8 +444,7 @@ wxSocketImpl *wxSocketImpl::Create(wxSocketBase& wxsocket)
 
 void wxSocketImplMSW::DoClose()
 {
-    wxSocketManager::Get()->
-        Uninstall_Callback(this, wxSOCKET_MAX_EVENT /* unused anyhow */);
+    wxSocketManager::Get()->Uninstall_Callback(this);
 
     closesocket(m_fd);
 }
index ce4926dafa9d8ec0da91b330465e1a6f83aafc17..07ae1a7f47a9f7893e0f14a89c3214a41917b7a6 100644 (file)
@@ -222,15 +222,14 @@ int wxSocketManagerMac::GetCFCallback(wxSocketImpl *socket, wxSocketNotify event
             return socket->IsServer() ? kCFSocketReadCallBack
                                       : kCFSocketConnectCallBack;
 
-        case wxSOCKET_LOST:
         case wxSOCKET_INPUT:
             return kCFSocketReadCallBack;
 
         case wxSOCKET_OUTPUT:
             return kCFSocketWriteCallBack;
 
-        case wxSOCKET_MAX_EVENT:
-            wxFAIL_MSG( "invalid wxSocketNotify" );
+        case wxSOCKET_LOST:
+            wxFAIL_MSG( "unexpected wxSocketNotify" );
             return 0;
 
         default: