In gRPC, a client application can directly call a method on a server application on a different machine as if it were a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub (referred to as just a client in some languages) that provides the same methods as the server.
gRPC 是基於 HTTP/2 協議的,所以即使他能做到雙向通信也會是類似websocket通信。而且grpc本身就是強區分客戶端服務端,不為雙向通信設計。
和socket相比:
gRPC 最大優勢是編碼使用protobuf,具備語言兼容性。使用 protocol buffers 的好處,包括高效的序列號,簡單的 IDL 以及容易進行接口更新。 --不過反過來講實際只使用protorbuf編碼或者json編碼同樣可具備語言兼容性。
但是它和socket通信本身就是不同的東西,要解決的問題完全就是不同的。