Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to make the move from WCF to gRPC so that I can use .NET5. I am stuck unable to proceed because I need to have multiple programs (hosting gRPC servers) using the same port. In WCF it was fairly simple - you needed to have NetTcpPortSharing service running and then specify that port sharing is enabled in the binding as shown below:


C#
Class1 c1 = new Class1();
ServiceHost host = new ServiceHost(this);

var binding = new CustomBinding();
var binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement();

binding.Elements.Add(binaryMessageEncodingBindingElement);

var tcpTransportBindingElement = new TcpTransportBindingElement
{
	PortSharingEnabled = true
};
binding.Elements.Add(tcpTransportBindingElement);

binding = new CustomBinding(binding);

host.AddServiceEndpoint(typeof(IClass1), binding, new Uri($"net.tcp://localhost:1055/IClass1"));
host.Open();


How is this done in gRPC?

What I have tried:

I am unable to find much of any discussion of this anywhere. If this cannot be done, it is going to keep us stuck in WCF and on .NET Framework 4.8 indefinitely.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900