// that both BSD and Winsock implementations actually use socket->m_server
// value to determine what exactly should be monitored so it needs to be
// set before calling these functions)
+ //
+ // the default event value is used just for the convenience of wxMSW
+ // implementation which doesn't use this parameter anyhow, it doesn't make
+ // sense to pass wxSOCKET_LOST for the Unix implementation which does use
+ // this parameter
virtual void Install_Callback(wxSocketImpl *socket,
- wxSocketNotify event = wxSOCKET_MAX_EVENT) = 0;
+ wxSocketNotify event = wxSOCKET_LOST) = 0;
virtual void Uninstall_Callback(wxSocketImpl *socket,
- wxSocketNotify event = wxSOCKET_MAX_EVENT) = 0;
+ wxSocketNotify event = wxSOCKET_LOST) = 0;
virtual ~wxSocketManager() { }
wxSOCKET_INPUT,
wxSOCKET_OUTPUT,
wxSOCKET_CONNECTION,
- wxSOCKET_LOST,
- wxSOCKET_MAX_EVENT
+ wxSOCKET_LOST
};
enum
switch ( event )
{
default:
- wxFAIL_MSG( "unexpected socket event" );
- // fall through
+ wxFAIL_MSG( "unknown socket event" );
+ return FD_INPUT; // we must return something
case wxSOCKET_LOST:
- // fall through
+ wxFAIL_MSG( "unexpected socket event" );
+ return FD_INPUT; // as above
case wxSOCKET_INPUT:
return FD_INPUT;
return FD_OUTPUT;
case wxSOCKET_CONNECTION:
- // FIXME: explain this?
+ // for server sockets we're interested in events indicating
+ // that a new connection is pending, i.e. that accept() will
+ // succeed and this is indicated by socket becoming ready for
+ // reading, while for the other ones we're interested in the
+ // completion of non-blocking connect() which is indicated by
+ // the socket becoming ready for writing
return socket->IsServer() ? FD_INPUT : FD_OUTPUT;
}
}
{
return new wxSocketImplMSW(wxsocket);
}
- virtual void Install_Callback(wxSocketImpl *socket, wxSocketNotify event);
- virtual void Uninstall_Callback(wxSocketImpl *socket, wxSocketNotify event);
+ virtual void Install_Callback(wxSocketImpl *socket,
+ wxSocketNotify event = wxSOCKET_LOST);
+ virtual void Uninstall_Callback(wxSocketImpl *socket,
+ wxSocketNotify event = wxSOCKET_LOST);
private:
static wxDynamicLibrary gs_wsock32dll;
* Disable event notifications (used when shutting down the socket)
*/
void wxSocketMSWManager::Uninstall_Callback(wxSocketImpl *socket_,
- wxSocketNotify WXUNUSED(event))
+ wxSocketNotify WXUNUSED(event))
{
wxSocketImplMSW * const socket = static_cast<wxSocketImplMSW *>(socket_);
void wxSocketImplMSW::DoClose()
{
- wxSocketManager::Get()->
- Uninstall_Callback(this, wxSOCKET_MAX_EVENT /* unused anyhow */);
+ wxSocketManager::Get()->Uninstall_Callback(this);
closesocket(m_fd);
}
return socket->IsServer() ? kCFSocketReadCallBack
: kCFSocketConnectCallBack;
- case wxSOCKET_LOST:
case wxSOCKET_INPUT:
return kCFSocketReadCallBack;
case wxSOCKET_OUTPUT:
return kCFSocketWriteCallBack;
- case wxSOCKET_MAX_EVENT:
- wxFAIL_MSG( "invalid wxSocketNotify" );
+ case wxSOCKET_LOST:
+ wxFAIL_MSG( "unexpected wxSocketNotify" );
return 0;
default: