public void UpdateDefaultServerSettings(NetConfig ServerConfig, NetConfig ClientConfig) { //Port And IP Settings PortNumeric.Value = ServerConfig.GetPort(); IPAddressBox.Text = "0.0.0.0"; //Server Configuration MaximumKeepAliveNumeric.Value = ServerConfig.GetMaxTimeOut(); MaximumPendingConNumeric.Value = ServerConfig.GetMaxBackLogConnections(); MaximumConNumeric.Value = ServerConfig.GetMaxConnections(); MaximumConSameIPNumeric.Value = ServerConfig.GetMaxSameIPConnections(); MaximumMessageSizeNumeric.Value = 10000; BufferSizeNumeric.Value = ServerConfig.GetBufferSize(); HeaderSizeNumeric.Value = ServerConfig.GetHeaderSize(); EnableDupIPAddressCheckBox.Checked = ServerConfig.GetEnableDuplicateIPS(); BlackListTextBox.Text = ServerConfig.GetBlackListPath(); //Client Configuration ClientMaximumMessageSizeNumeric.Value = ClientConfig.GetMaxMessageSize(); ClientBufferSizeNumeric.Value = ClientConfig.GetBufferSize(); ClientHeaderSizeNumeric.Value = ClientConfig.GetHeaderSize(); }
/// <summary> /// Starts Listening for incoming connections /// </summary> /// <returns></returns> public StartListenerResult StartListener() { StartListenerResult ListenerResult = null; try { OnlineClientsLock = new object(); Clients = new List <Operation>(); IPEndPoint ListenerEndPoint = new IPEndPoint(IPAddress.Any, Config.GetPort()); Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { LingerState = new LingerOption(false, 0), NoDelay = true }; Listener.Bind(ListenerEndPoint); Listener.Listen(Config.GetMaxBackLogConnections()); IsListening = true; IsShutdown = false; StartHeartBeat(); ListenerResult = new StartListenerResult(string.Format("Server Started Listening on port: {0}", Config.GetPort()), "StartListener", DateTime.Now, true); return(ListenerResult); } catch { if (ListenerResult == null) //Means from the Listen/Bind/EndPoint { ListenerResult = new StartListenerResult(string.Format("Server failed to listen on port: {0}", Config.GetPort()), "StartListener", DateTime.Now, false); } return(ListenerResult); } }