Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 3
0
 public void saea_enq(saea e)
 {
     lock (this)
     {
         socketAsync_Queue.Enqueue(e);
         Console.WriteLine(socketAsync_Queue.Count);
     }
 }
Ejemplo n.º 4
0
        protected saea saeaEntry()
        {
            saea _saea;

            if (this._receviceBuffLength > 0)
            {
                _saea = new saea(this._receviceBuffLength);
            }
            else
            {
                _saea = new saea();
            }
            return(_saea);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 6
0
 internal void processSend(saea e)
 {
 }