Books : Mastering Borland Delphi 2005: Update for Delphi 2006

Mastering Delphi Update for Delphi 2006

Chapter 19 

Indy 10 in Delphi 2006

If Indy 9 has remained identical to the version in Delphi 2005 (as it is a stable version and its development has stopped long ago), version 10 of the Internet Direct library is under active development. This is why the version in Delphi 2006 (10.1.5) is quite different from the one in Delphi 2005 (10.0.20). Historically, Indy has never been a library with a lot of care for backward compatibility, and the situation with the current version is no exception. Not only will you have to change low-level code written for Indy 9, but also for previous versions of Indy 10.

For example, compared to the version that shipped with Delphi 2005, the base class TIdTCPServer (defined in the IdTCpServer unit) now inherits from the new base class TIdCustomTCPServer (defined in the new IdCustomTCPServer unit). To make things a little more confusing, the Indy documentation available in Delphi 2006 has been updated to version 10.1.1, so that for example this new class is not covered at all. Now, I don't have the space here for a detailed list of the differences among the two versions, so I'll mention only the issues encountered while updating the examples covered in the book to make them work again.

One of the (positive) differences I noticed is that streams are now not integrated with Delphi own streams, and this is why the TIdStreamVCL wrapper class has been removed. I guess it could have stayed around for compatibility, with a warning message, but I don't want to engage in a discussion here.

In the Mastering Borland Delphi 2005 printed book I described the IdSock1 example, made of a client and a server application using sockets to communicate. This is one of the methods of the client application I had to modify because of this change in the stream architecture (I left the older code commented out in the listing) as we can now use the Delphi memory stream directly, without the wrapper:

procedure TFormClient.btnGetFileClick(Sender: TObject);


// wrapperStream: TIdStreamVCL;

  realStream: TMemoryStream;

  strSize: string;

  nSize: Integer;


  IdTCPClient1.SendCmd('getfile ' +

    TIdUri.ParamsEncode (edFileName.Text));

  ShowMessage (IdTCPClient1.LastCmdResult.Code + ' : ' +


  strSize := IdTCPClient1.IOHandler.ReadLn;

  nSize := StrToInt (strSize);

  realStream := TMemoryStream.Create;

// wrapperStream := TIdStreamVCL.Create (realStream, False);


    IdTCPClient1.IOHandler.ReadStream(realStream, nSize); // realStream

    realStream.Position := 0; // realStream

    Image1.Picture.Bitmap.LoadFromStream (realStream); // realStream



//    wrapperStream.Free;



A similar change is required for the server application of the example.

Having said this, it is important to note that all other applications, which use higher level Internet protocols, do not need any source code change and compile as they are, providing full compatibility with older versions.