-unsigned long wxSocketHandler::Count() const
-{
- return socks->Number();
-}
-
-// --------------------------------------------------------------
-// --------- wxSocketHandler "big" wait functions ---------------
-// --------------------------------------------------------------
-void handler_cbk(wxSocketBase& sock,
- wxSocketBase::wxRequestEvent WXUNUSED(flags),
- char *cdata)
-{
- int *a_wait = (int *)cdata;
-
- (*a_wait)++;
- sock.Notify(FALSE);
-}
-
-int wxSocketHandler::Wait(long seconds, long microseconds)
-{
- int i;
- int on_wait;
- wxSockWakeUp s_wake(NULL, &on_wait, -2);
- wxNode *node;
-
- for (node = socks->First(), i=0; node; node = node->Next(), i++)
- {
- wxSocketBase *sock = (wxSocketBase *)node->Data();
-
- sock->SaveState();
-
- sock->SetupCallbacks();
-
- sock->Callback(handler_cbk);
- sock->CallbackData((char *)&on_wait);
- }
- on_wait = 0;
- if (seconds != -1)
- s_wake.Start((seconds*1000) + (microseconds/1000), TRUE);
-
- while (!on_wait)
- PROCESS_EVENTS();
-
- for (node = socks->First(), i=0; node; node = node->Next(), i++)
- {
- wxSocketBase *sock = (wxSocketBase *)node->Data();
-
- sock->RestoreState();
- }
-
- if (on_wait == -2)
- return 0;
-
- return on_wait;
-}
-
-void wxSocketHandler::YieldSock()
-{
- wxNode *node;
-
- for (node = socks->First(); node; node = node->Next() )
- {
- wxSocketBase *sock = (wxSocketBase *)node->Data();
-
- sock->SaveState();
-
- sock->SetFlags(wxSocketBase::SPEED);
- if (sock->IsData())
- sock->DoRequests(wxSocketBase::EVT_READ);
- sock->DoRequests(wxSocketBase::EVT_WRITE);
-
- sock->RestoreState();
- }
-}
-
-// --------------------------------------------------------------
-// --------- wxSocketHandler: create and register the socket ----
-// --------------------------------------------------------------
-wxSocketServer *wxSocketHandler::CreateServer(wxSockAddress& addr,
- wxSocketBase::wxSockFlags flags)
-{
- wxSocketServer *serv = new wxSocketServer(addr, flags);
-
- Register(serv);
- return serv;
-}
-
-wxSocketClient *wxSocketHandler::CreateClient(wxSocketBase::wxSockFlags flags)
-{
- wxSocketClient *client = new wxSocketClient(flags);
-
- Register(client);
- return client;
-}
-
-#ifdef __WINDOWS__
-// --------------------------------------------------------------
-// --------- wxSocketHandler: Windows specific methods ----------
-// --------------------------------------------------------------
-
-UINT wxSocketHandler::NewMessage(wxSocketBase *sock)
-{
- internal->firstAvailableMsg++;
- smsg_list->Append(internal->firstAvailableMsg, sock);
- return internal->firstAvailableMsg;
-}
-
-void wxSocketHandler::DestroyMessage(UINT msg)
-{
- wxNode *node = smsg_list->Find(msg);
- delete node;
-}
-
-HWND wxSocketHandler::GetHWND() const
-{
- return internal->sockWin;
-}
-
-#endif
-
-bool wxSocketModule::OnInit()
-{
- wxSocketHandler::master = new wxSocketHandler();
- return TRUE;
-}
-
-void wxSocketModule::OnExit()
-{
- delete wxSocketHandler::master;
- wxSocketHandler::master = NULL;
-}
-
-#ifdef __WXMAC__
-void wxMacProcessSocketEvents() ;
-void wxMacProcessEvents()
-{
- wxMacProcessSocketEvents() ;
- (*GUSISpin)(SP_MISC, 0) ;
-}