For this exercise a program is open a socket to localhost on port 256 and send the message "hello socket world" before closing the socket.

Catching any exceptions or errors is not required.




program Sockets;
 
{$APPTYPE CONSOLE}
 
uses IdTCPClient;
 
var
  lTCPClient: TIdTCPClient;
begin
  lTCPClient := TIdTCPClient.Create(nil);
  try
    lTCPClient.Host := '127.0.0.1';
    lTCPClient.Port := 256;
    lTCPClient.Connect;
    lTCPClient.IOHandler.WriteLn('hello socket world');
  finally
    lTCPClient.Free;
  end;
end.