]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/socket.cpp
Fix hangups when using sockets under OS X.
[wxWidgets.git] / src / common / socket.cpp
index 09324181ae35d32b9a041a1fece18e4dd1c158d0..0bb79b219f3baa8b5aa621196c91a5a8cf0d2bfb 100644 (file)
@@ -533,7 +533,14 @@ wxSocketImpl *wxSocketImpl::Accept(wxSocketBase& wxsocket)
     if ( fd == INVALID_SOCKET )
         return NULL;
 
-    wxSocketImpl * const sock = Create(wxsocket);
+    wxSocketManager * const manager = wxSocketManager::Get();
+    if ( !manager )
+        return NULL;
+
+    wxSocketImpl * const sock = manager->CreateSocket(wxsocket);
+    if ( !sock )
+        return NULL;
+
     sock->m_fd = fd;
     sock->m_peer = wxSockAddressImpl(from.addr, fromlen);
 
@@ -1739,7 +1746,8 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr,
 {
     wxLogTrace( wxTRACE_Socket, wxT("Opening wxSocketServer") );
 
-    m_impl = wxSocketImpl::Create(*this);
+    wxSocketManager * const manager = wxSocketManager::Get();
+    m_impl = manager ? manager->CreateSocket(*this) : NULL;
 
     if (!m_impl)
     {
@@ -1897,7 +1905,8 @@ bool wxSocketClient::DoConnect(const wxSockAddress& remote,
     m_establishing = false;
 
     // Create and set up the new one
-    m_impl = wxSocketImpl::Create(*this);
+    wxSocketManager * const manager = wxSocketManager::Get();
+    m_impl = manager ? manager->CreateSocket(*this) : NULL;
     if ( !m_impl )
         return false;
 
@@ -1979,7 +1988,8 @@ wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr,
                 : wxSocketBase( flags, wxSOCKET_DATAGRAM )
 {
     // Create the socket
-    m_impl = wxSocketImpl::Create(*this);
+    wxSocketManager * const manager = wxSocketManager::Get();
+    m_impl = manager ? manager->CreateSocket(*this) : NULL;
 
     if (!m_impl)
         return;
@@ -2064,4 +2074,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule)
 wxFORCE_LINK_MODULE( socketiohandler )
 #endif
 
+// same for ManagerSetter in the MSW file
+#ifdef __WXMSW__
+    wxFORCE_LINK_MODULE( mswsocket )
+#endif
+
 #endif // wxUSE_SOCKETS