Sample code for 30+ languages & platforms
Delphi DLL

Send a Single Byte over a Socket

See more Socket/SSL/TLS Examples

Demonstrates Socket.SendByte, which sends one byte whose value is in the range 0 through 255.

Background. Fixed-size integers and length prefixes are common building blocks for application-defined binary protocols. Byte order is selectable, with big-endian being network byte order.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
socket: HCkSocket;
bTls: Boolean;
maxWaitMs: Integer;

begin
success := False;

socket := CkSocket_Create();

//  Connect to the server using TLS.
bTls := True;
maxWaitMs := 5000;
success := CkSocket_Connect(socket,'example.com',5000,bTls,maxWaitMs);
if (success = False) then
  begin
    Memo1.Lines.Add(CkSocket__lastErrorText(socket));
    Exit;
  end;

//  Send a single byte.  The value must be in the range 0 through 255.
success := CkSocket_SendByte(socket,65);
if (success = False) then
  begin
    Memo1.Lines.Add(CkSocket__lastErrorText(socket));
    Exit;
  end;
Memo1.Lines.Add('Byte sent.');

CkSocket_Dispose(socket);