예제 #1
0
        static void Main(string[] args)
        {
            const int Port = 50052;
            const int MaxMessageLengthBytes = Int32.MaxValue;

            var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);

            ChannelOption maxReceiveMessageLength = new ChannelOption(ChannelOptions.MaxMessageLength, MaxMessageLengthBytes);

            //ChannelOption maxSendMessageLength = new ChannelOption(ChannelOptions.MaxMessageLength, MaxMessageLengthBytes);
            ChannelOption[] grpcChannelOptions = { maxReceiveMessageLength };

            Server server = new Server(grpcChannelOptions)
                            //Server server = new Server()
            {
                Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
                Ports    = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };

            server.Start();

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

            server.ShutdownAsync().Wait();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            const int Port = 50052;

            var    features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);
            Server server   = new Server
            {
                Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
                Ports    = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };

            server.Start();
            Console.WriteLine("RouteGuide server listening on port " + Port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();
            server.ShutdownAsync().Wait();
        }