// First, close the file descriptor.
Close();
- m_internal->FinalizeSocket();
-
if (m_unread)
free(m_unread);
// Unregister from the handler database.
{
if (m_fd != INVALID_SOCKET)
{
- // Pause all running socket thread.
- m_internal->PauseSocket();
+ if (m_notify_state == TRUE)
+ Notify(FALSE);
// Shutdown the connection.
shutdown(m_fd, 2);
m_neededreq = flags;
if (m_neededreq == 0)
- m_internal->DisableWaiter();
+ m_internal->StopWaiter();
else
Notify(m_notify_state);
}
void wxSocketBase::Notify(bool notify)
{
+ m_notify_state = notify;
+ if (m_fd == INVALID_SOCKET)
+ return;
+
if (notify)
- m_internal->EnableWaiter();
+ m_internal->ResumeWaiter();
else
- m_internal->DisableWaiter();
- m_notify_state = notify;
+ m_internal->StopWaiter();
}
void wxSocketBase::OnRequest(wxRequestEvent req_evt)
// OldOnNotify(req_evt);
// We disable the event reporting.
- SetNotify(m_neededreq & ~notify);
+ m_neededreq &= ~notify;
}
}
SetEventType(type);
}
-wxObject *wxSocketEvent::Clone() const
+void wxSocketEvent::CopyObject(wxObject& obj_d) const
{
- wxSocketEvent *event = (wxSocketEvent *)wxEvent::Clone();
+ wxSocketEvent *event = (wxSocketEvent *)&obj_d;
+
+ wxEvent::CopyObject(obj_d);
event->m_skevt = m_skevt;
event->m_socket = m_socket;
-
- return event;
}
void wxSocketBase::OldOnNotify(wxRequestEvent evt)
SockRequest *buf = new SockRequest;
SaveState();
- m_internal->DisableWaiter();
+ m_internal->StopWaiter();
buf->buffer = buffer;
buf->size = nbytes;
buf->done = FALSE;
return;
}
- m_internal->InitializeSocket();
+ Notify(TRUE);
}
// --------------------------------------------------------------
{
int fd2;
- if ((fd2 = accept(m_fd, 0, 0)) < 0)
+ m_internal->AcquireFD();
+ if ((fd2 = accept(m_fd, 0, 0)) < 0) {
+ m_internal->ReleaseFD();
return FALSE;
+ }
+ m_internal->ReleaseFD();
struct linger linger;
linger.l_onoff = 0;
sock.m_fd = fd2;
sock.m_connected = TRUE;
- sock.m_internal->InitializeSocket();
+ sock.m_internal->ResumeWaiter();
return TRUE;
}
if (connect(m_fd, remote, len) != 0)
return FALSE;
- // Initializes the background threads ...
- // --------------------------------------
- m_internal->InitializeSocket();
-
// Enables bg events.
// ------------------
Notify(TRUE);
{
if (m_connected)
{
- SetNotify(m_neededreq & ~REQ_CONNECT);
+ m_neededreq &= ~REQ_CONNECT;
return;
}
m_connected = TRUE;
- OldOnNotify(EVT_CONNECT);
return;
}
wxSocketBase::OnRequest(evt);