internal BufferManager(Int32 totalBytes, Int32 bufferSize, ref LogMain logMain) { log = logMain; _NumBytes = totalBytes; _CurrentIndex = 0; _BufferSize = bufferSize; _FreeIndexPool = new Stack <Int32>(); }
internal SocketManager(Int32 numConnections, Int32 receiveBufferSize, ref LogMain logMain) { log = logMain; _ClientCount = 0; // 清理客户端连接数 _MaxConnectNum = numConnections; // 设置最大客户端连接数 _RevBufferSize = receiveBufferSize; // 设置缓冲区大小 try { _BufferManager = new BufferManager(receiveBufferSize * numConnections * opsToAlloc, receiveBufferSize, ref log); // 分配缓冲区, // 使得最大数量套接字可以有一个未完成读写同时发送到Socket _Pool = new SocketEventPool(numConnections); // 初始化套接字事件池 _MaxNumberAcceptedClients = new Semaphore(numConnections, numConnections); // 限制I/O大小范围 } catch (Exception ex) { log.AddLog(LogType.Error, $"因用户操作不当,此Bug已影响程序正常运行!\r\n错误信息:{ex.Message}"); } }
internal ProgramMain(String[] args, ref LogMain logMain) { log = logMain; _ProcessList = new List <ProcessItem>(); _SocketManager = new SocketManager(Convert.ToInt32(args[0]), Convert.ToInt32(args[1]), ref log); _SocketManager.ReceiveClientData += SocketManager_ReceiveClientData; _SocketManager.Init(); _SocketManager.Start(new IPEndPoint(IPAddress.Parse(args[2]), Convert.ToInt32(args[3]))); notifyIco.Visible = true; notifyIco.Icon = Resources.Icon; notifyIco.MouseDoubleClick += NotifyIco_MouseDoubleClick; _TSMI1.Text = "退出"; _TSMI1.Click += TSMI1_Click; _TSMI2.Text = "管理"; _TSMI2.Click += TSMI2_Click; _CMS.Items.AddRange(new ToolStripMenuItem[] { _TSMI2, _TSMI1 }); notifyIco.ContextMenuStrip = _CMS; }