mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Check socket descriptor limit. #153
When calling select(), there's an upper limit for the socket descriptor which is defined as FD_SETSIZE. When the socket descriptor is higher than FD_SETSIZE, a call to select() will not work as expected, at least for the proper sockets. This patch adds an error message for this case.
This commit is contained in:
parent
159176f5ba
commit
228038fa8a
@ -76,11 +76,20 @@ void SocketSelector::add(Socket& socket)
|
|||||||
SocketHandle handle = socket.getHandle();
|
SocketHandle handle = socket.getHandle();
|
||||||
if (handle != priv::SocketImpl::invalidSocket())
|
if (handle != priv::SocketImpl::invalidSocket())
|
||||||
{
|
{
|
||||||
FD_SET(handle, &m_impl->AllSockets);
|
if (handle < FD_SETSIZE)
|
||||||
|
{
|
||||||
|
FD_SET(handle, &m_impl->AllSockets);
|
||||||
|
|
||||||
int size = static_cast<int>(handle);
|
int size = static_cast<int>(handle);
|
||||||
if (size > m_impl->MaxSocket)
|
if (size > m_impl->MaxSocket)
|
||||||
m_impl->MaxSocket = size;
|
m_impl->MaxSocket = size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err() << "The socket can't be added to the selector because its "
|
||||||
|
<< "ID is too high. This is a limitation of your operating "
|
||||||
|
<< "system's FD_SETSIZE setting.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user