static void Main(string[] args) { int tcpport = int.Parse(AppSettingHelper.GetAppSetting("tcpport")); int numConnections = int.Parse(AppSettingHelper.GetAppSetting("numConnections")); int receiveBufferSize = int.Parse(AppSettingHelper.GetAppSetting("receiveBufferSize")); int overtime = int.Parse(AppSettingHelper.GetAppSetting("overtime")); int udpport = int.Parse(AppSettingHelper.GetAppSetting("udpport")); string istimer = AppSettingHelper.GetAppSetting("isTimer"); SimpleCRUD.SetConnectionString("", 0); Thread tlog = new Thread(TxtLogHelper.LoadData); tlog.Start(); TcpManager tcp = new TcpManager(numConnections, receiveBufferSize, overtime, tcpport); UdpManager udp = new UdpManager(receiveBufferSize, udpport, tcp); if (istimer == "1") { TimerManager tim = new TimerManager(tcp); } //ThreadPool.QueueUserWorkItem(new WaitCallback((object o) => //{ // TcpManager push1 = new TcpManager(numConnections, receiveBufferSize, overtime, 5556); //})); //ThreadPool.QueueUserWorkItem(new WaitCallback((object o) => //{ // TcpManager push1 = new TcpManager(numConnections, receiveBufferSize, overtime, 5557); //})); //ThreadPool.QueueUserWorkItem(new WaitCallback((object o) => //{ // TcpManager push1 = new TcpManager(numConnections, receiveBufferSize, overtime, 5558); //})); Console.Read(); }
/// <summary> /// 设置基本配置 /// </summary> /// <param name="receiveBufferSize">用于每个套接字I/O操作的缓冲区大小(接收端)</param> /// <param name="port">端口</param> public UdpManager(int receiveBufferSize, int port, TcpManager _tcp) { tcp = _tcp; server = new UdpServer(receiveBufferSize); server.OnReceive += OnReceive; server.OnSend += OnSend; server.Start(port); Console.WriteLine("Udp监听已启动,端口:" + port); TxtLogHelper.WriteLog("Udp监听已启动,端口:" + port); }