Exemplo n.º 1
0
 private void ReceiveCallback(IAsyncResult ar)
 {
     try
     {
         ar.AsyncWaitHandle.Close();
         this.m_ar_Recv = null;
         StateObjectForRecvData stateObjectForRecvData = (StateObjectForRecvData)ar.AsyncState;
         Socket workSocket = stateObjectForRecvData.workSocket;
         int    num        = workSocket.EndReceive(ar);
         if (num > 0)
         {
             MemoryStreamEx comunicationMem = this.m_ComunicationMem;
             Monitor.Enter(comunicationMem);
             try
             {
                 this.m_ComunicationMem.Write(stateObjectForRecvData.buffer, 0, num);
             }
             finally
             {
                 Monitor.Exit(comunicationMem);
             }
         }
         this.m_ar_Recv = workSocket.BeginReceive(stateObjectForRecvData.buffer, 0, 4096, SocketFlags.None, new AsyncCallback(this.ReceiveCallback), stateObjectForRecvData);
     }
     catch (Exception e)
     {
         this.DidDisconnect(e);
     }
 }
Exemplo n.º 2
0
 private void Receive()
 {
     try
     {
         StateObjectForRecvData stateObjectForRecvData = new StateObjectForRecvData();
         stateObjectForRecvData.workSocket = this.m_ClientSocket;
         this.m_ar_Recv = this.m_ClientSocket.BeginReceive(stateObjectForRecvData.buffer, 0, 4096, SocketFlags.None, new AsyncCallback(this.ReceiveCallback), stateObjectForRecvData);
     }
     catch (Exception e)
     {
         this.DidDisconnect(e);
     }
 }
Exemplo n.º 3
0
 private void Receive()
 {
     try
     {
         StateObjectForRecvData stateObjectForRecvData = new StateObjectForRecvData();
         stateObjectForRecvData.workSocket = this.m_ClientSocket;
         this.m_ar_Recv = this.m_ClientSocket.BeginReceive(stateObjectForRecvData.buffer, 0, 4096, SocketFlags.None, new AsyncCallback(this.ReceiveCallback), stateObjectForRecvData);
     }
     catch (Exception e)
     {
         this.DidDisconnect(e);
     }
 }