X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7f555861b7e50f335c7b929bb76be38e9ebd69c5..f5419957e5794f2d10f4e125f77b2c2e2cd222d6:/src/common/socket.cpp diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 53ddde5e89..d8c728b137 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -89,6 +89,7 @@ ///////////////////////////////////////////////////////////////////////////// // wxSocket headers ///////////////////////////////////////////////////////////////////////////// +#include "wx/module.h" #define WXSOCK_INTERNAL #include "wx/sckaddr.h" #include "wx/socket.h" @@ -117,7 +118,7 @@ #endif #ifdef __WXMOTIF__ -#define wxAPP_CONTEXT wxTheApp->appContext +#define wxAPP_CONTEXT ((XtAppContext)wxTheApp->GetAppContext()) #endif #ifdef __WINDOWS__ @@ -153,6 +154,17 @@ int PASCAL FAR __WSAFDIsSet(SOCKET fd, fd_set FAR *set) // Some patch ///// END ///////////////////////////////////////////////////////////////////////////// +// -------------------------------------------------------------- +// Module +// -------------------------------------------------------------- +class wxSocketModule: public wxModule { + DECLARE_DYNAMIC_CLASS(wxSocketModule) +public: + wxSocketModule() {} + bool OnInit(); + void OnExit(); +}; + // -------------------------------------------------------------- // ClassInfos // -------------------------------------------------------------- @@ -162,6 +174,7 @@ IMPLEMENT_CLASS(wxSocketServer, wxSocketBase) IMPLEMENT_CLASS(wxSocketClient, wxSocketBase) IMPLEMENT_CLASS(wxSocketHandler, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent) +IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule) #endif class wxSockWakeUp : public wxTimer { @@ -1034,8 +1047,10 @@ void wxSocketBase::WantSpeedBuffer(char *buffer, size_t nbytes, if (ret < 0) { m_lcount = 0; m_error = errno; - } else + } else { m_lcount = ret; + m_error = 0; + } } void wxSocketBase::WantBuffer(char *buffer, size_t nbytes, @@ -1246,9 +1261,9 @@ bool wxSocketClient::Connect(wxSockAddress& addr_man, bool WXUNUSED(wait) ) return TRUE; } -bool wxSocketClient::WaitOnConnect(long seconds) +bool wxSocketClient::WaitOnConnect(long seconds, long microseconds) { - int ret = _Wait(seconds, 0, REQ_CONNECT | REQ_LOST); + int ret = _Wait(seconds, microseconds, REQ_CONNECT | REQ_LOST); if (ret) m_connected = TRUE; @@ -1291,6 +1306,11 @@ extern char wxPanelClassName[]; LRESULT APIENTRY _EXPORT wxSocketHandlerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + if(message==WM_DESTROY) + { + ::SetWindowLong(hWnd, GWL_WNDPROC, (LONG) DefWindowProc); + return DefWindowProc(hWnd, message, wParam, lParam); + } wxSocketHandler *h_sock = (wxSocketHandler *)GetWindowLong(hWnd, GWL_USERDATA); wxNode *node = h_sock->smsg_list->Find(message); wxSocketBase *sock; @@ -1541,5 +1561,15 @@ HWND wxSocketHandler::GetHWND() const #endif +bool wxSocketModule::OnInit() { + wxSocketHandler::master = new wxSocketHandler(); + return TRUE; +} + +void wxSocketModule::OnExit() { + delete wxSocketHandler::master; + wxSocketHandler::master = NULL; +} + #endif // __WXSTUBS__