Exemple #1
0
 void ReleaseSocketAsync(saea e)
 {
     if (e._socket != null)
     {
         Console.WriteLine("A client  {0}  Release", e._socket.RemoteEndPoint);
         try
         {
             if (e._socket != null)
             {
                 e._socket.Shutdown(SocketShutdown.Both);
             }
         }
         catch
         {
         }
         try
         {
             if (e._socket != null)
             {
                 e._socket.Close();
             }
         }
         catch
         {
         }
         initConfig.socketasync_queue.saea_enq(e);
     }
 }
Exemple #2
0
        internal void processReceive(saea e)
        {
            try
            {
                //aq aq = e._aq;
                if (e.BytesTransferred > 0 && e.SocketError == SocketError.Success)
                {
                    Console.WriteLine(e.BytesTransferred);



                    if (!e._socket.ReceiveAsync(e))
                    {
                        Console.WriteLine("------------------------------------------------------------------");
                        //同步接收完成处理事件
                        processReceive(e);
                    }
                }
                else
                {
                    ReleaseSocketAsync(e);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
 public void saea_enq(saea e)
 {
     lock (this)
     {
         socketAsync_Queue.Enqueue(e);
         Console.WriteLine(socketAsync_Queue.Count);
     }
 }
Exemple #4
0
        protected saea saeaEntry()
        {
            saea _saea;

            if (this._receviceBuffLength > 0)
            {
                _saea = new saea(this._receviceBuffLength);
            }
            else
            {
                _saea = new saea();
            }
            return(_saea);
        }
Exemple #5
0
        private void handle_Socket(Socket se)
        {
            //aq aq = new aq(se._socket);
            //this.OnConnected(aq);
            //取出队列
            saea _socketasync = initConfig.socketasync_queue.saea_dep();

            _socketasync._socket = se;
            try
            {
                if (!_socketasync._socket.ReceiveAsync(_socketasync))
                {
                    //同步接收完成处理事件
                    _socketasync.processReceive(_socketasync);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #6
0
 internal void processSend(saea e)
 {
 }