...

/

Server Streaming RPC

Server Streaming RPC

Learn about server-streaming RPC in gRPC and how to implement it.

Server streaming RPC

Server streaming RPC is one of the four types of RPC (Remote Procedure Call) in gRPC. In this type of RPC, the client sends a single message to the server and receives a stream of response messages from the server. This type of RPC is useful when the client needs to receive a large amount of data from the server. The client opens a channel to the server and then sends a message. The server sends a stream of messages in response to the client's request.

readFile RPC in FTP service

An example of a server streaming RPC in the FTP service is readFile where the client makes a request to receive a file from the server. We can define the readFile RPC in the ftp_service.proto file. The client opens a channel and sends a request to read a file on the server. The client sends the metadata about the file. When the readFile RPC is called, the server expects a metadata message containing the file name. The server checks if the file exists and then sends it to the client in chunks. When the server signals the end of the stream, the client responds with a success (or failure) message. It should be noted that the server uses the same connection to send the stream of data to the ...