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

uses
  IdTCPClient, IdSSLOpenSSL, SysUtils;

const
  HOST = 'localhost';
  PORT = 12345;

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

begin
  (* open connection *)
  ssl := TIdSSLIOHandlerSocketOpenSSL.Create;
  ssl.sslOptions.VerifyMode := [];
  ssl.sslOptions.VerifyDepth := 0;
  ssl.sslOptions.SSLVersions := [sslvTLSv1_2];
  ssl.sslOptions.Mode := sslmClient;
  cli := TIdTCPClient.Create;
  cli.IOHandler := ssl;
  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.

