(* Collection of code snippets by Arne Vajhøj *)
(* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) *)
program PlainTextClientHigh;

uses
  IdTCPClient, SysUtils;

const
  HOST = 'localhost';
  PORT = 12345;

var
  cli : TIdTCPClient;
  v, v2 : string;
  a, b, c : integer;

begin
  (* open connection *)
  cli := TIdTCPClient.Create;
  cli.Connect(HOST, PORT);
  (* send a and b *)
  a := 123;
  b := 456;
  cli.Socket.WriteLn(IntToStr(a) + ' ' + IntToStr(b));
  (* receive c and print *)
  c := StrToint(cli.Socket.ReadLn);
  writeln(c);
  (* send v *)
  v := 'ABC';
  cli.Socket.WriteLn(v);
  (* received v2 and print *)
  v2 := cli.Socket.ReadLn;
  writeln(v2);
  (* close connection *)
  cli.Disconnect;
  cli.Free;
end.

