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
@ -75,6 +75,8 @@ void SocketSelector::add(Socket& socket)
|
||||
{
|
||||
SocketHandle handle = socket.getHandle();
|
||||
if (handle != priv::SocketImpl::invalidSocket())
|
||||
{
|
||||
if (handle < FD_SETSIZE)
|
||||
{
|
||||
FD_SET(handle, &m_impl->AllSockets);
|
||||
|
||||
@ -82,6 +84,13 @@ void SocketSelector::add(Socket& socket)
|
||||
if (size > m_impl->MaxSocket)
|
||||
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