Boost logo

Boost Users :

Subject: [Boost-users] R: Re: [ASIO] Do coroutines allow serving multiple clients at once?
From: mmarkd9_at_[hidden]
Date: 2016-10-10 12:08:36


Thanks, does spawning a coroutine also spawn a new thread? I'd be inclined to think so from what you told me

----Messaggio originale----

Da: "Oliver Kowalke" <oliver.kowalke_at_[hidden]>

Data: 10-ott-2016 15.19

A: "boost-users"<boost-users_at_[hidden]>

Ogg: Re: [Boost-users] [ASIO] Do coroutines allow serving multiple clients at once?

2016-10-10 9:44 GMT+02:00 mmarkd9_at_[hidden] <mmarkd9_at_[hidden]>:
I'd like to know if this code is able to serve multiple clients connecting at the same time to the server.

I would say no. You spawn only one coroutine that calls in the for-loop async. operations of accept(), read() and write() in a sequence.
No other client is able to connect to your server, e.g. connect() on the client side returns, until you enter accept() again.

In order to serve multiple clients at the same time you need to spawn a coroutine that accepts new connections and for each client request (read()/write() operations) you need to spawn a new coroutine.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net