title: My "not connected" TCP Client is connected?
body: <p>Given the following code, which is the first code having anything to do with my <code>TIdTCPClient</code> when my program runs   </p>
  
  <pre><code>try
    if not TCPclient.Connected then
    begin
       TraceInfo(TCPclient.Host + ' Server not connected - reconnect');
       TCPclient.Connect();
  
       TCPclient.GetResponse(200);
       ConnectedToServer();
       TraceInfo(TCPclient.Host + ' Connect OK');
    end;
  
  except   // when trying to connect to server
      on EIdAlreadyConnected : Exception do
      begin
         TraceWarning(TCPclient.Host + ' Attempt to Connect when already connected');
      end
      else    // Failed to connect for any other reason
      begin
         TraceError(TCPclient.Host + ' Connect FAILED !!!!');
         Exit; 
      end;
  end;
  
  // we either connected or noticed that we were already connected
  try
    resultCode := TCPclient.SendCmd(theMessage);
    if resultCode = 200 then
    begin
       TraceInfo(TCPclient.Host + ' Sent OK');
       Result := TCPclient.LastCmdResult.Text.Text;
       DisconnectFromServer(TCPclient);
       Exit;
    end
    else
    begin
       TraceWarning(TCPclient.Host + ' Send rejected by server (result code = ' + IntToStr(resultCode) + ') !!!!');
        DisconnectFromServer(TCPclient);
        Exit;
    end;
  
  except
    on E : Exception do       // EIdNotConnected
    begin
       Result := '';
       TraceError(TCPclient.Host + ' Send FAILED (exception "' + E.ClassName + '")');
    end;
  </code></pre>
  
  <p>end;</p>
  
  <p>I cannot understand why the trace log says  </p>
  
  <pre><code>00:00:00 [10.21.18.211 Server not connected - reconnect]    12:21:38 PM
  00:00:01 [10.21.18.211 Attempt to Connect when already connected]   12:21:40 PM
  00:00:01 [10.21.18.211 FAILED to connect to server] 12:21:40 PM
  00:00:01 [10.21.18.211 Send FAILED (exception "EIdNotConnected")]   12:21:40 PM
  </code></pre>
  
  <p>Can anyone see somthing obviously wrong with my code? Or can I provide more information to help you to help me?</p>
  
  <p>Thanks in advance  </p>
  
  <hr>
  
  <p>Update, for clarification:</p>
  
  <p>How can we have </p>
  
  <p>if not TCPclient.Connected then
    begin
       TraceInfo(TCPclient.Host + ' Server not connected - reconnect');</p>
  
  <p>and then </p>
  
  <pre><code> TraceError(TCPclient.Host + ' Send FAILED (exception "' + E.ClassName + '")');
  </code></pre>