#include <wx/timer.h>
#include <wx/utils.h>
+// Not enough OS behaviour defined for wxStubs
+#ifndef __WXSTUBS__
+
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/////////////////////////////////////////////////////////////////////////////
// wxSocket headers
/////////////////////////////////////////////////////////////////////////////
+#include "wx/module.h"
#define WXSOCK_INTERNAL
#include "wx/sckaddr.h"
#include "wx/socket.h"
#endif
#ifdef __WXMOTIF__
-#define wxAPP_CONTEXT wxTheApp->appContext
+#define wxAPP_CONTEXT ((XtAppContext)wxTheApp->GetAppContext())
#endif
#ifdef __WINDOWS__
// Some patch ///// END
/////////////////////////////////////////////////////////////////////////////
+// --------------------------------------------------------------
+// Module
+// --------------------------------------------------------------
+class wxSocketModule: public wxModule {
+ DECLARE_DYNAMIC_CLASS(wxSocketModule)
+public:
+ wxSocketModule() {}
+ bool OnInit();
+ void OnExit();
+};
+
// --------------------------------------------------------------
// ClassInfos
// --------------------------------------------------------------
IMPLEMENT_CLASS(wxSocketClient, wxSocketBase)
IMPLEMENT_CLASS(wxSocketHandler, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule)
#endif
class wxSockWakeUp : public wxTimer {
bool wxSocketBase::GetPeer(wxSockAddress& addr_man) const
{
struct sockaddr my_addr;
- size_t len_addr = sizeof(my_addr);
+ int len_addr = sizeof(my_addr);
if (m_fd < 0)
return FALSE;
-#ifdef __WINDOWS__
- if (getpeername(m_fd, (struct sockaddr *)&my_addr, (int *)&len_addr) < 0)
-#else
- if (getpeername(m_fd, (struct sockaddr *)&my_addr, (unsigned int *)&len_addr) < 0)
-#endif
+ if (getpeername(m_fd, (struct sockaddr *)&my_addr,
+ &len_addr) < 0)
return FALSE;
addr_man.Disassemble(&my_addr, len_addr);
bool wxSocketBase::GetLocal(wxSockAddress& addr_man) const
{
struct sockaddr my_addr;
- size_t len_addr = sizeof(my_addr);
+ int len_addr = sizeof(my_addr);
if (m_fd < 0)
return FALSE;
-#ifdef __WINDOWS__
- if (getsockname(m_fd, (struct sockaddr *)&my_addr, (int *)&len_addr) < 0)
-#else
- if (getsockname(m_fd, (struct sockaddr *)&my_addr, (unsigned int *)&len_addr) < 0)
-#endif
+ if (getsockname(m_fd, (struct sockaddr *)&my_addr,
+ &len_addr) < 0)
+
return FALSE;
addr_man.Disassemble(&my_addr, len_addr);
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,
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;
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;
}
#endif
+
+bool wxSocketModule::OnInit() {
+ wxSocketHandler::master = new wxSocketHandler();
+ return TRUE;
+}
+
+void wxSocketModule::OnExit() {
+ delete wxSocketHandler::master;
+ wxSocketHandler::master = NULL;
+}
+
+#endif
+ // __WXSTUBS__