public static void ReceiveCallback(IAsyncResult res)
 {
     try
     {
         ReceiveObject ro  = (ReceiveObject)res.AsyncState;
         int           len = sock.EndReceive(res);
         ro.sb.Append(Encoding.ASCII.GetString(ro.buffer, 0, len));
         if (ro.sb.Length > 0)
         {
             ServerProcessing.processReceivedMessage(ro.sb.ToString());
         }
         receiveDone.Set();
     }
     catch (SocketException) //when server crash or close
     {
         if (closingApp)
         {
             return;
         }
         MessageBox.Show("Utracono połaczenie z serwerem, uruchom aplikacje ponownie!");
         System.Windows.Forms.Application.Exit();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return;
     }
 }
Esempio n. 2
0
 public static void ReceiveCallback(IAsyncResult res)
 {
     try
     {
         ReceiveObject ro  = (ReceiveObject)res.AsyncState;
         int           len = sock.EndReceive(res);
         ro.sb.Append(Encoding.ASCII.GetString(ro.buffer, 0, len));
         if (ro.sb.Length > 0)
         {
             ServerProcessing.processReceivedMessage(ro.sb.ToString());
         }
         receiveDone.Set();
     }
     catch (Exception e)
     {
         return;
         //TODO Implement faults
     }
 }