private void ProcessAccept(SocketAsyncEventArgs e) { //try //{ if (e.SocketError == SocketError.Success) { Socket EstablishedConnection = e.AcceptSocket; Operation Client = new Operation(EstablishedConnection, Config, PacketManager); if (false) //IsClientBlackListed(Client) { //SetOnClientBlackList(Client.EndPoint.Address, "Connection blocked"); //Disconnect(Client); } else { if (Clients.Count <= Config.GetMaxConnections()) { AddClient(Client); SetOnClientConnect(Client); } else { SetOnClientDisconnect(Client, "Server reached the maximum number of clients"); Disconnect(Client); } } StartAccept(e); } else { if (IsListening == true && IsShutdown == false) { SetOnException(new Exception("Server Exception (ProcessAccept): Could not process the accepted connections due to server shutdown")); Shutdown(); } } //} //catch (Exception ex) //{ // if (IsListening == true && IsShutdown == false) // { // SetOnException(new Exception(string.Format("Server Exception (ProcessAccept): {0}", ex.Message))); // Shutdown(); // } //} }
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(); }