Just more asynchronous stuff!
Alright, so I now have a working asynchronous socket program for my main chatting application, and it\'s working really well! However I
If you are programming under a Posix compliant system, you should be able to use the poll() function instead of select() and this will do away with the limit that you mention. Alternatively, you can call select() multiple times in succession but be certain to use a relatively short timeout.
You don't say what OS you're using, but for most, if you want to use file descriptors above 1024 with select, you can #define FD_SETSIZE
to be a larger number BEFORE #including sys/socket.h. Unfortunately, this doesn't work on Linux.
Yes, the FD_SETSIZE has a limit of 1024. You can easily check that by looking at the select.h header. People have tried to increase the limit, but the reports vary from "working" to "crashing" after a while. If you need that many connections, use poll
instead.
A very good article to read.
For really large numbers of sockets look into using a library like libevent.
The library can abstract several OS-specific advanced features like /dev/poll, kqueue, epoll, and event ports. With these you can handle really vast numbers of connections.