Extend and rename wxSocketImpl::UnblockAndRegisterWithEventLoop()
In addition to unblocking and registering the socket, also support using this function to make the socket blocking and unregistering it from the event loop, if its flags include wxSOCKET_BLOCK. This was already half-done by wxMSW, which took wxSOCKET_BLOCK presence into account in its implementation, but not by the Unix implementation. Now do it under all platforms, as this will be useful for switching a previously non-blocking socket to blocking mode. Finally, rename the function to better reflect what it really does. See #12886.
This commit is contained in:
@@ -73,12 +73,13 @@ private:
|
||||
wxCloseSocket(m_fd);
|
||||
}
|
||||
|
||||
virtual void UnblockAndRegisterWithEventLoop() wxOVERRIDE
|
||||
virtual void UpdateBlockingState() wxOVERRIDE
|
||||
{
|
||||
int trueArg = 1;
|
||||
ioctl(m_fd, FIONBIO, &trueArg);
|
||||
// Make this int and not bool to allow passing it to ioctl().
|
||||
const int isBlocking = (GetSocketFlags() & wxSOCKET_BLOCK) != 0;
|
||||
ioctl(m_fd, FIONBIO, &isBlocking);
|
||||
|
||||
EnableEvents();
|
||||
DoEnableEvents(wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG, !isBlocking);
|
||||
}
|
||||
|
||||
// enable or disable notifications for socket input/output events
|
||||
|
Reference in New Issue
Block a user