static void Main(string[] args) { var socketBufferSize = int.Parse(ConfigurationManager.AppSettings["SocketBufferSize"]); var setting = new Setting { TcpConfiguration = new TcpConfiguration { SocketBufferSize = socketBufferSize } }; ECommonConfiguration .Create() .UseAutofac() .RegisterCommonComponents() .UseLog4Net() .RegisterUnhandledExceptionHandler(); var bindingIP = ConfigurationManager.AppSettings["BindingAddress"]; var serverIP = string.IsNullOrEmpty(bindingIP) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(bindingIP); var server = new SocketRemotingServer("Server", new IPEndPoint(serverIP, 5000)); server.RegisterRequestHandler(100, new RequestHandler()); server.Start(); Console.ReadLine(); }
static void Main(string[] args) { var maxSendPacketSize = int.Parse(ConfigurationManager.AppSettings["MaxSendPacketSize"]); var socketBufferSize = int.Parse(ConfigurationManager.AppSettings["SocketBufferSize"]); var setting = new Setting { TcpConfiguration = new TcpConfiguration { MaxSendPacketSize = maxSendPacketSize, SocketBufferSize = socketBufferSize } }; ECommonConfiguration .Create(setting) .UseAutofac() .RegisterCommonComponents() .UseLog4Net() .RegisterUnhandledExceptionHandler(); var serverIP = ConfigurationManager.AppSettings["ServerAddress"]; var mode = ConfigurationManager.AppSettings["Mode"]; var ipAddress = string.IsNullOrEmpty(serverIP) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(serverIP); _remotingClient = new SocketRemotingClient(new IPEndPoint(ipAddress, 5000)); _remotingClient.Start(); var parallelThreadCount = int.Parse(ConfigurationManager.AppSettings["ParallelThreadCount"]); var actions = new List<Action>(); for (var i = 0; i < parallelThreadCount; i++) { actions.Add(() => SendMessageAsync(mode)); } _watch.Start(); Parallel.Invoke(actions.ToArray()); Console.ReadLine(); }