static int Run() { // Locate path to certificates folder in distribution. string rootDir = DllPathResolver.FindDistributionRootDir(); string certsDir = Path.Combine(rootDir, "certs"); // Initialize RCF. RCFProto.Init(); // Create server. RcfProtoServer server = new RcfProtoServer(); // Bind Protobuf service. SearchServiceImpl myService = new SearchServiceImpl(); server.BindService(myService); // Add the endpoints that this server will support. List <Endpoint> endpoints = new List <Endpoint>(); endpoints.Add(new TcpEndpoint(50001)); endpoints.Add(new HttpEndpoint(50002)); endpoints.Add(new HttpsEndpoint(50003)); endpoints.Add(new Win32NamedPipeEndpoint("DemoServerPipe")); foreach (Endpoint endpoint in endpoints) { server.AddEndpoint(endpoint); } // By default, the server serves clients on a single thread. Here, we are // configuring the server to use a thread pool with up to 10 threads. ThreadPool threadPool = new ThreadPool(1, 10); threadPool.SetThreadName("RCFProto Server"); server.SetThreadPool(threadPool); // Configure SSL certificate. // Load certificate from PFX format. string certPath = Path.Combine(certsDir, "certA.p12"); Certificate cert = new PfxCertificate(certPath, "", "localhost"); server.SetCertificate(cert); server.SetSslImplementation(SslImplementation.Schannel); // Start the server. server.Start(); // Wait for shutdown. SearchServiceImpl.ShutdownEvent.WaitOne(); System.Console.WriteLine("Shutting down server."); // Stop server. server.Stop(); return(0); }