> Hello,
> Im designing a communication program which has to listen to 5 different
> ports at all time, and handle async messages from the ports.
> What design is better: using Selector or using different thread for
> each socket?
I think it's really a matter of which you find easier to work
with. At this level, you don't need multiple threads for
performance, and you don't need a selector to avoid swamping with
too many threads.
A problem you may have to deal with if you use multiple threads
is locking adn thread-safety issues when sharing data between
threads.
A problem you may have to deal with if you use selector is error
conditions on individual ports, and how they affect a selector
which is attempting to select on all 5 ports - possibly remove
the erroring port from the selector set?
Steve