Here is my scenario:
- Multiple sockets on one application
- I want to receive and send on any number of these sockets
The only solution I have found so far to get around threading issues and bizzare exceptions is:
- Each socket has it's own thread
- Each socket has it's own concurrent queue which it constantly checks to see if it has a message to send
- To send from a specific socket, regardless of thread, then you just add the message to the correct socket concurrent queue
However, this get's pretty costly. I am not a big fan of threading in general, and I have a niggly feeling there's a much better way. I am thinking about the poller - it allows you to receive from multiple sockets without needing to create a new thread per socket (as far as I'm aware). If this is right, is there no way to get it to send pending messages?
Otherwise, is multiple threads my only option? Thanks