I have an application which acts as a server and a client. So, it accepts incoming connections, but also establishes connections. I have a class dedicated to the listening, where the listening sockets reside. Another class establishes connections.
Whether I accept or open a connection, the connected socket goes into another class which does I/O on the connected socket(s). The problem is in this class. I currently use select(), which blocks until something happens on the sockets that are set and I am not sure how to add my new sockets to the fd_set. I could use a timeout value, like 1000ms and add all sockets in my set after the timeout, but i was hoping for a better solution...
I do this on windows, so i was considering the other mechanisms, like overlapped I/O, IOCPs etc, but I don't have much experience with them and I don't see any viable solution to my problem. However, I think that any of the async solutions would be better, but i still don't see anything that solves this.
Maybe my design is just wrong, but any pointer that you can give me would be much appreciated.
Thanks