title: Indy Dynamic Create Server Client connecting error 10061
body: <p>I am having trouble dynamically creating some INDY communication.  I have not used Indy before and I can't get the server set up right.  I get the error 10061.  I have added a rule to the fire wall to allow this application and the port.  It works if I use TServerSocket and TClientSocket but I need to use Indy.</p>
  
  <p>This code does not work</p>
  
  <pre><code>procedure TForm3.Button3Click(Sender: TObject);
  var
    temp          : TIdSocketHandles;
  
  begin
    fIdTCPServer1 := TIdTCPServer.Create(nil);
    fIdTCPClient1 := TIdTCPClient.Create(nil);
    temp := TIdSocketHandles.Create(fIdTCPServer1);
    temp.Add.IP := 'xxx.xx.xxx.xx';//'localhost'; //gave error when tryingn to use local host
    temp.Add.Port := 20200;
  
    fIdTCPServer1.Bindings := temp;
    fIdTCPServer1.OnExecute := IdTCPServer1Execute;
    fIdTCPServer1.StartListening();
  
  
    fIdTCPClient1.Port := 20200;
    fIdTCPClient1.Host := 'xxx.xx.xxx.xx';//'localhost';
    fIdTCPClient1.Connect;  //error 10061 here
  
    fIdTCPClient1.IOHandler.WriteLn('Some message');
  end;
  procedure TForm3.IdTCPServer1Execute(AContext: TIdContext);
  var
    inStr : String;
  
  begin
    inStr := AContext.Connection.IOHandler.ReadLn;
    ShowMessage('Server received : ' + inStr);
  end;
  </code></pre>
  
  <p>This code works</p>
  
  <pre><code>procedure TForm3.Button1Click(Sender: TObject);
  begin
    serverSocket1 := TServerSocket.Create(nil);
    clientSocket1 := TClientSocket.Create(nil);
  
    serverSocket1.Port := 20200;
    serverSocket1.OnClientRead := ServerSocket1ClientRead;
    serverSocket1.Active := True;
  
  
    clientSocket1.Port := 20200;
    clientSocket1.Host := 'localhost';
    clientSocket1.Active := True;
    clientSocket1.Socket.SendText('Some message');
  end;
  
  procedure TForm3.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket);
  var
    inStr  : String;
  begin
    inStr := Socket.ReceiveText();
    ShowMessage('Server received : ' + inStr);
  end;
  </code></pre>