haha , thanks a lot for your help. I think threads could be a headache but Im still willing to at least learn a threaded implementation because its good for knowledge.
But obviously select() makes things a lot easier. thanks for introducing this.
For now I think I will try the approach
having a set of listening sockets (for each port)
then for each socket have a fd_set of client sockets
so if i == that socket (I get a new connection) I will accept() the new fd and add it to its respective set.
... or something similar to this approach