/// <summary>
        /// 启动服务器
        /// </summary>
        /// <returns>异步TCP服务器</returns>
        public void Start()
        {
            if (!IsRunning)
            {
                IsRunning = true;
                _serverSock.Bind(new IPEndPoint(this.Address, this.Port));
                //_serverSock.Connect(new IPEndPoint(IPAddress.Any, 0));

                AsyncSocketUDPState so = new AsyncSocketUDPState();
                so.workSocket = _serverSock;

                _serverSock.BeginReceiveFrom(so.buffer, 0, so.buffer.Length, SocketFlags.None,
                                             ref so.remote, new AsyncCallback(ReceiveDataAsync), null);


                //EndPoint sender = new IPEndPoint(IPAddress.Any, 0);

                //_serverSock.BeginReceiveFrom(_recvBuffer, 0, _recvBuffer.Length, SocketFlags.None,
                //    ref sender, new AsyncCallback(ReceiveDataAsync), sender);

                //BeginReceive 和 BeginReceiveFrom的区别是什么

                /*_serverSock.BeginReceive(_recvBuffer, 0, _recvBuffer.Length, SocketFlags.None,
                 *  new AsyncCallback(ReceiveDataAsync), null);*/
            }
        }
 /// <summary>
 /// 关闭一个与客户端之间的会话
 /// </summary>
 /// <param name="state">需要关闭的客户端会话对象</param>
 public void Close(AsyncSocketUDPState state)
 {
     if (state != null)
     {
         //_clients.Remove(state);
         //_clientCount--;
         //TODO 触发关闭事件
     }
 }
 public AsyncSocketUDPEventArgs(byte[] msg, AsyncSocketUDPState state)
 {
     this._msg   = msg;
     this._state = state;
     IsHandled   = false;
 }
 public AsyncSocketUDPEventArgs(AsyncSocketUDPState state)
 {
     this._state = state;
     IsHandled   = false;
 }
 private void RaiseOtherException(AsyncSocketUDPState state)
 {
     RaiseOtherException(state, null);
 }