'Indy 9 to Indy 10 App: Connection refused

I'm porting and old Delphi 2009 app with Indy 9 to Delphi 11 with Indy 10:

// *************** Indy Version 9:
IdTCPClient1.Host := '123.456.789.012';
IdTCPClient1.Port := 123;
IdTCPClient1.Connect;
IdTCPClient1.OpenWriteBuffer;
IdTCPClient1.Write(Data);
i :=  IdTCPClient1.ReadInteger(True);
x := IdTCPClient1.ReadLn('</root>', 20000, 1500);
// Works OK

// *************** Indy Version 10
XMLStream := TMemoryStream.Create;
XMLDoc1.XML.SaveToStream(XMLStream);
IdTCPClient1.Host := '123.456.789.012';
IdTCPClient1.Port := 123;
IdTCPClient1.Connect;
IdTCPClient1.Socket.Open;
IdTCPClient1.Socket.WriteBufferOpen;
IdTCPClient1.Socket.Write(XMLStream, XMLStream.Size);
i := IdTCPClient1.Socket.ReadInt32(True);
x := IdTCPClient1.Socket.ReadLn('</root>', 20000, 1500);
// Socket Error # 10061 Connection refused.

Both versions are executing in the same PC/User... Any help will be appreciated. Francisco

    //Still receiving Socket Error # 10061: Connection Refused
    IdTCPClient1.Host := '123.456.789.0';
    IdTCPClient1.Port := 55065;
    IdTCPClient1.Connect;
    IdTCPClient1.Socket.WriteBufferOpen;
    IdTCPClient1.Socket.Write(XMLStream, XMLStream.Size);
    i := IdTCPClient1.Socket.ReadInt32(True);
    sResp := IdTCPClient1.Socket.ReadLn('</root>', 20000, 1500);
    IdTCPClient1.Socket.WriteBufferFlush;
    IdTCPClient1.Socket.Close;
    IdTCPClient1.Disconnect;
    // I omitted some code like try, except


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source