Esempio n. 1
0
 private void EstablishConnection()
 {
     try
     {
         if (client != null)
         {
             if (client.Connected)
                 return;
             throw new DisconnectedException();
         }
         client = new TcpClient();
         client.Connect(configuration.Host);
     }
     catch(Exception exception)
     {
         if(client != null)
             client.SafeDispose();
         client = null;
         throw new CannotConnectException(string.Format("Cannot connect to {0}", configuration.Host), exception);
     }
 }