I'm digging out to grpc as a replacement for WCF. I'm using .Net 5 and looking for a stand-alone server solution (No ASP involved --> Concole application). That already limits the available hints and tutorials a lot :-(
Using packages grpc.Core (2.34.0), grpc.Tools (2.34.0), grpc.Net.Common (2.34.0) and Google.Protobuf (3.14.0) it is quite easy to spawn a basic server (GreeterImpl comes from some tutorial):
Server server = new Server();
server.Services.Add(Greeter.BindService(new GreeterImpl()));
server.Ports.Add(new ServerPort("localhost", 5001, ServerCredentials.Insecure));
server.Start();
Console.ReadKey();
This works fine. Server listens on port 5001.
In WCF self-hosted (based uppon http.sys) it was quite easy to host multiple WCF servers just by specifying a different directory (minified code):
1st assembly
List<Uri> baseAddresses = new List<Uri>();
baseAddresses.Add(new Uri("http://localhost:5001/Service1.svc"));
host = new ServiceHost(typeof(GenericService), baseAddresses.ToArray());
host.Open();
2nd assembly
List<Uri> baseAddresses = new List<Uri>();
baseAddresses.Add(new Uri("http://localhost:5001/Service2.svc"));
host = new ServiceHost(typeof(GenericService), baseAddresses.ToArray());
host.Open();
It even worked with a present IIS serving other stuff on port 5001
How do I start a second server (different assembly) using the same port but different directory?
I could not find any suggestion on how to achieve that.