Modbus Components

Are yes the problem with Indy is getting the documentation

But thanks to ADUG I and others have copies

Indy 10 comes with Delphi

A Client sample App from that documentation

Introduction to Indy

unit ClientMain;

interface

uses
  Windows, Messages, SysUtils, Classes,
  Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
  IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient;

type
  TformMain = class(TForm)
    Client: TIdTCPClient;
    IdAntiFreeze1: TIdAntiFreeze;
    Panel1: TPanel;
    Panel2: TPanel;
    memoInput: TMemo;
    lboxResults: TListBox;
    Panel3: TPanel;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
  public
  end;

var
  formMain: TformMain;

implementation

{ R *.DFM }
procedure TformMain.Button2Click(Sender: TObject);
begin
  memoInput.Clear;
  lboxResults.Clear;
end;

procedure TformMain.Button1Click(Sender: TObject);
var
  i: integer;
  s: string;
begin
  butnLookup.Enabled := true;
  try
    lboxResults.Clear;
    with Client do
    begin
      Connect;
      try
        lboxResults.Items.Add(ReadLn);
        for i := 0 to memoInput.Lines.Count - 1 do
        begin
          WriteLn('ZipCode ' + memoInput.Lines[i]);
          lboxResults.Items.Add(memoInput.Lines[i]);
          s := ReadLn;
          if s = '' then
          begin
            s := '-- No entry found for this zip code.';
          end;
          lboxResults.Items.Add(s);
          lboxResults.Items.Add('');
        end;
        WriteLn('Quit');
      finally
        Disconnect;
      end;
    end;
  finally
    butnLookup.Enabled := true;
  end;
end;

end.

The only parts that are Indy specific are the Client component and the Button1Click method.
Client is a TIdTCPClient and is a component on the form. The following properties were altered from the default:
• Host = 127.0.0.1 - Host was set to contact a server on the same machine as the client.
• Port = 6000 - An arbitrary number for this demo. This is the port that the client will contact the server with.
Button1Click is a method that is hooked to the OnClick event of Button1. When the button is clicked it executes this method.
The Indy portion of this method can be reduced to the following:

  1. Connect to Server ( Connect; )
  2. Read welcome message from theserver.
  3. For each line the user entered in the TMemo:
  4. Send request to server (WriteLn('ZipCode ’ + memoInput.Lines[i]):wink:
  5. Read response from server (s := ReadLn;)
  6. Send Quit command ( WriteLn(‘Quit’); )
  7. Disconnect (Disconnect;)