コード例 #1
0
        public static void Main(string[] args)
        {
            object registerLock = new object();

            List <ServiceEntry> entries = new List <ServiceEntry>();


            Server server = new Server
            {
                Services = { ServiceRegistration.BindService(new ServiceRegistrationImpl(registerLock, entries)), ServiceCatalog.BindService(new ServiceCatalogImpl(registerLock, entries)) },
                Ports    = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("Greeter server listening on port " + Port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }