Ejemplo n.º 1
0
 protected static void ReceiveCallback(IAsyncResult ar)
 {
     try
     {
         var state         = (State)ar.AsyncState;
         var socket        = state.socket;
         var bytesReceived = socket.EndReceive(ar);
         PacketReceiver.receive(bytesReceived, socket, state);
         socket.BeginReceive(state.buffer, 0, State.BufferSize, 0, ReceiveCallback, state);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
Ejemplo n.º 2
0
 protected static void ReceiveCallback(IAsyncResult ar)
 {
     try
     {
         State  state         = (State)ar.AsyncState;
         Socket socket        = state.socket;
         int    bytesReceived = socket.EndReceive(ar);
         PacketReceiver.receive(bytesReceived, socket, state);
         socket.BeginReceive(state.buffer, 0, State.BufferSize, 0, ReceiveCallback, state);
     }
     catch (Exception)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("\n[UCS]      Client has been disconnected!");
         Console.ResetColor();
     }
 }