Hi, There would be a unique stream per call. The threading model you use will depend a lot on the application and the performance requirements.
I think there is a slight confusion here about the sync and async API. In the async API, reads and writes do not block, i.e., the calls should return immediately. To make sure that the reads and writes actually complete, the async API requires completion_queue.Next() to be called. Yes, it is possible to have concurrent reads and writes. The transport layer in gRPC would take care of the synchronization. On Sunday, March 17, 2019 at 2:31:58 AM UTC-7, x.pa...@gmail.com wrote: > > Hello, > > I want to create in C++ a chat server: One serve to serve X clients at the > same time, when a client sends a message, the server broadcast. > I found this example: https://github.com/grpc/grpc/pull/8934/files which > is close to what I want, but it contains only one client connecting (If I'm > not mistaken). > > If I want multiple clients, do I need to create one stream per client (in > a thread ?) or all the clients can use the same stream ? > If multiple streams it means I will have all threads waiting to read a > message on their stream, and when someone receives one, the "main thread" > after the call to "Next" will loop on all streams to write the message. > > Is it possible to write a message on a stream while another thread is > blocking on "Read" ? > > If you have any advice to at least not let me go on a wrong direction, > shout :) > > Thanks. > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To post to this group, send email to grpc-io@googlegroups.com. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/fa99c51d-0483-4e6a-b9d2-3ddf5aaf745e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.