// named) OnRequest() method
void NotifyOnStateChange(wxSocketNotify event);
- // FIXME: this one probably isn't needed here at all
- virtual void Notify(bool WXUNUSED(notify)) { }
-
// TODO: make these fields protected and provide accessors for those of
// them that wxSocketBase really needs
//protected:
m_fds[0] =
m_fds[1] = -1;
- m_use_events = false;
m_enabledCallbacks = 0;
}
int Read(void *buffer, int size);
int Write(const void *buffer, int size);
- //attach or detach from main loop
- void Notify(bool flag);
// wxFDIOHandler methods
virtual void OnReadWaiting();
EnableEvents();
}
- // enable or disable notifications for socket input/output events but only
- // if m_use_events is true; do nothing otherwise
- virtual void EnableEvents()
- {
- if ( m_use_events )
- DoEnableEvents(true);
+ // enable or disable notifications for socket input/output events
+ void EnableEvents() { DoEnableEvents(true); }
+ void DisableEvents() { DoEnableEvents(false);
}
- void DisableEvents()
- {
- if ( m_use_events )
- DoEnableEvents(false);
- }
-
- // really enable or disable socket input/output events, regardless of
- // m_use_events value
+ // really enable or disable socket input/output events
void DoEnableEvents(bool enable);
- // enable or disable events for the given event if m_use_events; do nothing
- // otherwise
+ // enable or disable events for the given event
//
// notice that these functions also update m_detected: EnableEvent() clears
// the corresponding bit in it and DisableEvent() sets it
protected:
- // true if socket should fire events
- bool m_use_events;
-
// descriptors for input and output event notification channels associated
// with the socket
int m_fds[2];
// Shutdown and close the socket
Close();
- // Supress events from now on
+ // Suppress events from now on
Notify(false);
// schedule this object for deletion
void wxSocketBase::Notify(bool notify)
{
m_notify = notify;
- if (m_impl)
- m_impl->Notify(notify);
}
void wxSocketBase::SetNotify(wxSocketEventFlags flags)
}
// Setup the socket as server
- m_impl->Notify(m_notify);
m_impl->SetLocal(addr_man.GetAddress());
if (GetFlags() & wxSOCKET_REUSEADDR) {
m_impl->SetPeer(addr_man.GetAddress());
const wxSocketError err = m_impl->CreateClient();
- //this will register for callbacks - must be called after m_impl->m_fd was initialized
- m_impl->Notify(m_notify);
-
if (err != wxSOCKET_NOERROR)
{
if (err == wxSOCKET_WOULDBLOCK)
if (!m_impl)
return;
- m_impl->Notify(m_notify);
// Setup the socket as non connection oriented
m_impl->SetLocal(addr.GetAddress());
if (flags & wxSOCKET_REUSEADDR)
#else
ioctl(connection->m_fd, FIONBIO, &arg);
#endif
- if (m_use_events)
- connection->Notify(true);
return connection;
}
-void wxSocketImplUnix::Notify(bool flag)
-{
- if (flag == m_use_events)
- return;
- m_use_events = flag;
- DoEnableEvents(flag);
-}
-
void wxSocketImplUnix::DoEnableEvents(bool flag)
{
wxSocketManager * const manager = wxSocketManager::Get();
if ((ret == 0) && m_stream)
{
/* Make sure wxSOCKET_LOST event gets sent and shut down the socket */
- if (m_use_events)
- {
- m_detected = wxSOCKET_LOST_FLAG;
- OnReadWaiting();
- return 0;
- }
+ m_detected = wxSOCKET_LOST_FLAG;
+ OnReadWaiting();
+ return 0;
}
else if (ret == -1)
{
void wxSocketImplUnix::EnableEvent(wxSocketNotify event)
{
- if (m_use_events)
- {
- m_detected &= ~(1 << event);
- wxSocketManager::Get()->Install_Callback(this, event);
- }
+ m_detected &= ~(1 << event);
+ wxSocketManager::Get()->Install_Callback(this, event);
}
void wxSocketImplUnix::DisableEvent(wxSocketNotify event)
{
- if (m_use_events)
- {
- m_detected |= (1 << event);
- wxSocketManager::Get()->Uninstall_Callback(this, event);
- }
+ m_detected |= (1 << event);
+ wxSocketManager::Get()->Uninstall_Callback(this, event);
}
int wxSocketImplUnix::Recv_Stream(void *buffer, int size)