I am writing an application in C for linux, which uses 2 separate third-party libraries. Both libraries are asynchronous and use select(). They also provide an API which returns the file descriptors they wait on. My intention is to pass these into my own select() and then return control back to whichever library when their own fd values are set.
I think I've got most of it written, but I have trouble at the point where the select() parameters are concerned: Both libraries do not give individual file descriptors, but pointers to their read and write fd_sets. I need to combine the returned fd_sets from these libraries into one fd_set for read, one fd_set for write, etc.
Any suggestions on how I can combine 2 fd_sets into one resulting fd_set?
Addendum Sorry! I should have been clearer.. these libraries only return the fd_sets... I don't know the number of FDs in each set so that I can do a for loop and set each FD individually.. is there a simple way of determining this given just an fd_set?