- delete socks;
-
-#ifdef __WINDOWS__
- delete smsg_list;
-
- ::DestroyWindow(internal->sockWin);
- WSACleanup();
- win_initialized = 0;
-
- delete internal;
-#endif
-}
-
-// --------------------------------------------------------------
-// --------- wxSocketHandler registering functions --------------
-// --------------------------------------------------------------
-void wxSocketHandler::Register(wxSocketBase* sock)
-{
- wxNode *node;
-
- for (node = socks->First(); node != NULL; node = node->Next()) {
- wxSocketBase* s = (wxSocketBase*)node->Data();
-
- if (s == sock)
- return;
- }
-
- if (sock) {
- socks->Append(sock);
- sock->SetHandler(this);
- sock->SetupCallbacks();
- }
-}
-
-void wxSocketHandler::UnRegister(wxSocketBase* sock)
-{
- wxNode *node;
-
- for (node = socks->First(); node; node = node->Next()) {
- wxSocketBase* s = (wxSocketBase*)node->Data();
-
- if (s == sock) {
- delete node;
- sock->DestroyCallbacks();
- sock->SetHandler(NULL);
- return;
- }
- }
-}
-
-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)