Example #1
0
 private void ReadRequests()
 {
     while (Client.Connected)
     {
         try
         {
             Request request = Client.NextRequest();
             if (request != null)
             {
                 Client.Server.HandleRequest(request);
             }
         }
         catch (JsonSerializationException)
         {
             Log.Error("JsonSerializationException");
         }
         catch (JsonReaderException)
         {
             Log.Error("JsonReaderException");
         }
         catch (VeryLongStringException)
         {
             Log.Error("VeryLongStringException");
         }
         catch (SocketClosedException)
         {
             Client.Close();
         }
         catch (SocketException)
         {
             Client.Close();
         }
     }
 }
        public int ReadInt()
        {
            byte[] sizeBuffer = new byte[4];
            int    size       = socket.Receive(sizeBuffer);

            if (size == 0)
            {
                client.Close();
                throw new SocketClosedException();
            }
            int result = BitConverter.ToInt32(sizeBuffer, 0);

            Log.Debug($"{client.Name}.ReadInt: {result}");
            return(result);
        }