In your Main method, create a new instance of the server and add your gRPC service.
main.cs
staticvoidMain(string[] args){
var host = "localhost";
var port = 50051;
var server = new Server
{
Services = { Greeter.BindService(new MyGreeterService()) },
Ports = { new ServerPort(host, port, ServerCredentials.Insecure) }
};
server.Start();
Console.WriteLine($"Server listening on {host}:{port}");
Console.ReadKey();
}
374 chars
14 lines
Start your gRPC server and you're done!
Note: Don't forget to update the Greeter namespace to match your proto file.