Skip to content

C++ client - C# server implementation over grpc connection with async unary and Bidiractional stream messages. Integration test proj using gtest .

License

Notifications You must be signed in to change notification settings

dahanmoshe1991/Grpc_Async_Bidi_ClientServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GRpc_Async_Client_Server

C++ client - C# server implementation over grpc connection with async unary and Bidiractional stream messages

This solution is include async Unary & Bidirectional messages implematation for C++ client & C# server. During my research, I found the grpc documentation is lacking. Therefore, I'm releasing my working version.

✨ ✨

Features

  • C++ client
  • C# server
  • Unary messages
  • Async Unary Messages (using completion queue)
  • Bidirectional Stream Messages.
Please refer to the Class diagram for a better understanding of the working interface

Grpc

- Documentation

- Community

Installation

If you want to create a grpc c++ project follow this:

First, install vcpkg package manager on your system using the official instructions: in powerShell:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg

Depanding on your OS:

  1. Bootstrap on Linux:
./bootstrap-vcpkg.sh
  1. Bootstrap on Windows instead:
 ./bootstrap-vcpkg.bat

Next, install gRPC using vcpkg package manager:

./vcpkg install grpc

for user wide integration use:

 vcpkg integrate install

for specific project integration use:

vcpkg integrate project

follow instructions output in Powershell With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste: Install-Package ****** -Source "****\vcpkg\scripts\buildsystems" (replace ** with powershell output)

After grpc installed -> update googlePath macro to vcpckg installation location + "installed\x64-windows\include" (choose your relavant os folder)

If you want to create a grpc c# project follow this:

Generate grpc stub files

In order to use grpc communication(Google's Protocol Buffers) we need to define a service, specifying the methods that can be called remotely with their parameters and return types.

we do this inside our .proto files. To learn more about protocol buffers see the protocol buffers documentation

gRPC uses protoc with a special gRPC plugin to generate code from your proto file.

use these commands to generate c++ code:

$(protobufPath)protoc -I=$(protosPath) -I $(googlePath) --cpp_out=$(ProjectDir)Generated $(protosPath)*.proto
$(protobufPath)protoc -I $(protosPath) -I $(googlePath) --grpc_out=$(ProjectDir)Generated --plugin=protoc-gen-grpc=$(grpcPath)grpc_cpp_plugin.exe $(protosPath)*.proto 

where :

  • protobufPath -> protoc.exe location inside installed grpc
  • protosPath -> location of *.proto files to generate from.
  • googlePath -> vcpckg installation location + "installed\x64-windows\include"
  • --cpp_out/--grpc_out -> output location
  • grpcPath -> googlePath + \grpc\x64-windows\tools\grpc\

recommendation

Insert the above lines as a preBuild event to always keep your source code up to date.

License

MIT

About

C++ client - C# server implementation over grpc connection with async unary and Bidiractional stream messages. Integration test proj using gtest .

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published