[asio] Multiple listeners on different ports?
Hi, My application needs to listen on one port for a certain service and another for another service. Service A is a registration-type service and service B is a typical client-server response service. I need to be able to handle concurrent connections on both ports. I would also like to use asio streams rather than the async read/write operations (its just easier!). What I had thought of was spawning two threads for the two services. My questions are: * Is it possible to use streams with concurrent connections? * Would asio be unhappy if I used the above "design"? * Is there a better suggestion/example I can look at? Thanks, Sohail
Sohail Somani writes:
What I had thought of was spawning two threads for the two services. My questions are:
* Is it possible to use streams with concurrent connections?
Yep.
* Would asio be unhappy if I used the above "design"?
There is no shared data between distinct tcp::iostream objects, so there should be no problem.
* Is there a better suggestion/example I can look at?
My only question for you is how many concurrent connections do you expect to have? Just one at a time for each of the services, with each service using an iterative server design? If you might have more than one concurrent connection per service then you're going to need more than two threads. Cheers, Chris
participants (2)
-
Christopher Kohlhoff
-
Sohail Somani