Skip to content

Instantly share code, notes, and snippets.

@huacnlee
Created September 6, 2010 03:09
Show Gist options
  • Save huacnlee/566591 to your computer and use it in GitHub Desktop.
Save huacnlee/566591 to your computer and use it in GitHub Desktop.
procedure TForm2.Button1Click(Sender: TObject);
var
iType: Integer;
buf: array[0..8191] of char;
UDP: TidUDPClient;
begin
UDP := TIdUDPClient.Create(nil);
try
UDP.Host := '127.0.0.1';
UDP.Port := 1108;
UDP.Active := True;
FillChar(buf, 8192, 0);
iType := 1001;
CopyMemory(@buf[0], @iType, 4);
CopyMemory(@buf[4], @Edit1.Text[1], Length(Edit1.Text));
UDP.SendBuffer(buf, Length(Edit1.Text)+4);
UDP.ReceiveTimeout := 3000;
Memo1.Lines.Add(UDP.ReceiveString());
finally
UDP.Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment