static void Main(string[] args) { //from Grpc.Core Server server = null; try { //Grpc server instance with insecure connection on localhost //insecure as out client is also going to run on same machine //this is just for a demo purpose and real practice it will replaced by //meaningful entity server = new Server { Services = { NumberService.BindService(new NumberServiceEx()) }, Ports = { new ServerPort("localhost", serverPort, ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine($"The server is actively listening on port {serverPort}..."); Console.ReadKey(); } catch (IOException ex) { Console.WriteLine($"Unable to start a server!\r\nMore details - {ex.Message}."); } finally { server?.ShutdownAsync().Wait(); } }
public SampleServer() { server = new Server() { Services = { NumberService.BindService(new NumberServiceImpl()) }, Ports = { new ServerPort("localhost", 56567, ServerCredentials.Insecure) } }; }