/// <summary> /// 构造函数 /// </summary> /// <param name="listenPort">监听的端口</param> public JYTCPServer(int listenPort) { _server = new JYAsyncTcpServer(listenPort); if (_server == null) { throw new Exception("监听端口创建失败!"); } _bufferSize = 1024 * 1024 * 10;//10MB }
/// <summary> /// 服务器构造函数 /// </summary> /// <param name="listenPort">监听的端口号</param> /// <param name="dataType">缓存区存放资料的类型</param> /// <param name="bufferSize">缓存区大小</param> public JYTCPServer(int listenPort, ChannelDataType dataType = ChannelDataType.DataStream, int bufferSize = 131072) { LocalIP = Dns.GetHostAddresses(Dns.GetHostName()).Where(x => x.AddressFamily == AddressFamily.InterNetwork).First(); _server = new JYAsyncTcpServer(LocalIP, listenPort); _server.ReceiveBufferSize = (uint)bufferSize; _clientsInfo = new List <ClientInformation>(); _dataType = dataType; if (_server == null) { throw new Exception("监听端口创建失败!"); } }