[grpc-c++] gRPC polling for incoming packets from multiple sockets

162 views
Skip to first unread message

Maysam Mehraban

unread,
Oct 12, 2017, 12:54:52 PM10/12/17
to grpc.io
Hello,

I am looking into possibility of listening on different sockets at once. To handle multiple socket connection at the same fd_set can be used in Linux. I have seen that gRPC also support this functionality with having epoll based pollset.

https://github.com/grpc/grpc/blob/18df25228cfa1f97fc5cca9176fbaef64c0e4221/doc/epoll-polling-engine.md

I intend to call different services in async mode and providing a service at the same time. Therefore, I was thinking about having a poll-set consist of client sockets waiting for async responses and server sockets. It seems to be possible in gRPC. I haven't been able to find anything in gRPC API that exposes construction of a poll-set.

Hence, my question is how to use this capability of gRPC?

Does gRPC manages this automatically? In that case how can I wait for incoming messages?

Many Thanks in advance.

Best// Maysam

ista.s...@gmail.com

unread,
Oct 31, 2017, 5:50:15 AM10/31/17
to grpc.io
Hey!

I am also looking into the same kind of handling mechanism to leverage gRPC promises one step forward 
but unfortunately there is no such example or explanations in the web that I found (:-

It's really appreciated if anyone from Core team can reply something here or update the doc with examples that really shows it.

Looking forward -- waiting for a reply ! Thanks.


Regards
ista

Muxi Yan

unread,
Oct 31, 2017, 7:09:21 PM10/31/17
to grpc.io
Hi! If you are using gRPC C++, you can create server and client calls on the same completion queue so that when you wait for event on that completion queue you wait for those from both sides.

Ista Ranjan Samanta

unread,
Nov 1, 2017, 5:01:25 AM11/1/17
to grpc.io
Hi,

Thanks a lot for providing the accomplish able approach towards it. Yes, I am also using C++ gRPC. 

I was carefully following this concrete example -- https://github.com/grpc/grpc/tree/master/examples/cpp/helloworld On the server you get a completion queue in this line -- auto cq = builder.AddCompletionQueue();   // Line no 59 in greeter_async_server.cc file

On the client side,you provide a completion queue -- CompletionQueue cq;    //Line no 58 in greeter_async_client.cc file

So, do you mean to use the same cq ? Just to be super clear to understand your comment. Thanks.

Regards
ista

Yang Gao

unread,
Nov 7, 2017, 6:21:54 PM11/7/17
to grpc.io
Yes. A ServerCompletionQueue is a CompletionQueue and you can use it for client events as well.
Reply all
Reply to author
Forward
0 new messages