internal static void StartServer(enumGC_Mode GC_Mode) { try { IDictionary props = new Hashtable(); switch (GC_Mode) { case enumGC_Mode.GC_TCP: Debug.WriteLine(" Starting GC_TCP Server"); props["name"] = "GTCP1"; props["priority"] = "100"; props["port"] = "8737"; // Null entries specify the default formatters. GenuineTcpChannel channelTCP = new GenuineTcpChannel(props, null, null); ChannelServices.RegisterChannel(channelTCP, false); break; case enumGC_Mode.GC_HTTP: Debug.WriteLine(" Starting GC_HTTP Server"); props["name"] = "ghttp"; props["priority"] = "100"; // Null entries specify the default formatters. GenuineHttpServerChannel channelHttp = new GenuineHttpServerChannel(props, null, null); ChannelServices.RegisterChannel(channelHttp, false); break; } // bind the server RemotingServices.Marshal(new ChatServer(), "ChatServer.rem"); Debug.WriteLine("Server has been started."); } catch (Exception ex) { Debug.WriteLine("Exception: {0}. Stack trace: {1}.", ex.Message, ex.StackTrace); } }
protected void Application_Start(Object sender, EventArgs e) { Console.SetOut(GlobalConsole); try { // setup remoting System.Configuration.ConfigurationSettings.GetConfig("DNS"); GenuineGlobalEventProvider.GenuineChannelsGlobalEvent += new GenuineChannelsGlobalEventHandler(GenuineChannelsEventHandler); //GlobalLoggerContainer.Logger = new BinaryLog(@"c:\tmp\server.log"); Hashtable properties = new Hashtable(); properties["MaxContentSize"] = "5000000"; properties["PersistentConnectionSendPingAfterInactivity"] = "15000"; properties["MaxQueuedItems"] = "100000"; properties["MaxTotalSize"] = "100000000"; properties["Compression"] = "false"; properties["MaxTimeSpanToReconnect"] = "5000"; GenuineHttpServerChannel channel = new GenuineHttpServerChannel(properties, null, null); ChannelServices.RegisterChannel(channel); // bind the service RemotingServices.Marshal(new ChatServer(), "ChatServer.rem"); } catch (Exception ex) { Console.WriteLine("Exception: {0} Stack trace: {1}.", ex.Message, ex.StackTrace); } }