コード例 #1
0
		internal protected TcpServerChannel(TcpServerChannelManager channelManager, int channelId) : base(channelId)
		{
			if(channelManager == null)
				throw new ArgumentNullException("channelManager");

			//设置通道管理器
			_channelManager = channelManager;

			//初始化接受连接的时间
			_acceptedTime = new DateTime(1900, 1, 1);
		}
コード例 #2
0
        internal protected TcpServerChannel(TcpServerChannelManager channelManager, int channelId) : base(channelId)
        {
            if (channelManager == null)
            {
                throw new ArgumentNullException("channelManager");
            }

            //设置通道管理器
            _channelManager = channelManager;

            //初始化接受连接的时间
            _acceptedTime = new DateTime(1900, 1, 1);
        }
コード例 #3
0
		public TcpServer([TypeConverter(typeof(IPEndPointConverter))]IPEndPoint localEP) : base("TcpServer", localEP)
		{
			//创建接受异步事件参数
			_acceptAsyncArgs = new SocketAsyncEventArgs();

			//挂载接受异步事件参数的Completed事件处理委托
			_acceptAsyncArgs.Completed += ((sender, asyncArgs) =>
			{
				if(asyncArgs.LastOperation == SocketAsyncOperation.Accept)
				{
					this.OnAcceptCompleted(asyncArgs);
				}
			});

			//创建当前服务器通道管理器
			_channelManager = this.CreateChannelManager();
		}
コード例 #4
0
        protected override void Dispose(bool disposing)
        {
            //停止当前服务
            this.Stop();

            if (disposing)
            {
                var channelManager = _channelManager;

                if (channelManager != null)
                {
                    channelManager.Dispose();
                }
            }

            //将通道管理器置空表示当前类已被处置
            _channelManager = null;

            //调用基类同名方法
            base.Dispose(disposing);
        }
コード例 #5
0
		public TcpServer([TypeConverter(typeof(IPEndPointConverter))]IPEndPoint address) : base("TcpServer")
		{
			if(address == null)
				throw new ArgumentNullException("address");

			_address = address;

			//创建接受异步事件参数
			_acceptAsyncArgs = new SocketAsyncEventArgs();

			//挂载接受异步事件参数的Completed事件处理委托
			_acceptAsyncArgs.Completed += ((sender, asyncArgs) =>
			{
				if(asyncArgs.LastOperation == SocketAsyncOperation.Accept)
				{
					this.OnAcceptCompleted(asyncArgs);
				}
			});

			//创建当前服务器通道管理器
			_channelManager = this.CreateChannelManager();
		}
コード例 #6
0
        public TcpServer([TypeConverter(typeof(IPEndPointConverter))] IPEndPoint address) : base("TcpServer")
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            _address = address;

            //创建接受异步事件参数
            _acceptAsyncArgs = new SocketAsyncEventArgs();

            //挂载接受异步事件参数的Completed事件处理委托
            _acceptAsyncArgs.Completed += ((sender, asyncArgs) =>
            {
                if (asyncArgs.LastOperation == SocketAsyncOperation.Accept)
                {
                    this.OnAcceptCompleted(asyncArgs);
                }
            });

            //创建当前服务器通道管理器
            _channelManager = this.CreateChannelManager();
        }
コード例 #7
0
		protected override void Dispose(bool disposing)
		{
			//停止当前服务
			this.Stop();

			if(disposing)
			{
				var channelManager = _channelManager;

				if(channelManager != null)
					channelManager.Dispose();
			}

			//将通道管理器置空表示当前类已被处置
			_channelManager = null;

			//调用基类同名方法
			base.Dispose(disposing);
		}
コード例 #8
0
 internal protected TcpServerChannel(TcpServerChannelManager channelManager, int channelId) : base(channelId, channelManager)
 {
     //初始化接受连接的时间
     _acceptedTime = new DateTime(1900, 1, 1);
 }