dermesser / libsocket

The ultimate socket library for C and C++, supporting TCP, UDP and Unix sockets (DGRAM and STREAM) on Linux, FreeBSD, Solaris. See also my uvco library for a refreshed version!
https://borgac.net/~lbo/doc/libsocket/
Other
797 stars 195 forks source link

Revamp selectset by using poll() under the hood instead of select() #49

Closed dsorber closed 7 years ago

dsorber commented 7 years ago

I ran into issues when using libsocket++ in an application that happened to have a large number of file descriptors open. I figured out that the issue was caused by the known limitation of select() and FD_SETSIZE (see "BUGS" section: http://man7.org/linux/man-pages/man2/select.2.html).

This eliminates problems with select() if the socket's file descriptor is greater than FD_SETSIZE (which is 1024 most of the time). The interface to selectset remains exactly the same so nothing should break.

This modification works very well in my testing so I figured that it may be useful to others as well.

dsorber commented 7 years ago

I made the requested changes and ran the tests (examples++/test.sh) with no issues.

dermesser commented 7 years ago

Thank you for your contribution!