Example #1
0
 // Function that call to write function of tcpClient and catches all
 // The exceptions that can happen.
 private string WriteToServer(string variable)
 {
     try
     {
         client.Write(variable);
         return(EverythingIsGood);
     }
     catch (ObjectDisposedException)
     {
         client.Disconnect();
         return(WriteObjectDisposedException);
     }
     catch (InvalidOperationException)
     {
         client.Disconnect();
         return(WriteInvalidOperationException);
     }
     catch (IOException)
     {
         client.Disconnect();
         return(WriteIOException);
     }
     catch (Exception)
     {
         client.Disconnect();
         return(RegularException);
     }
 }