I have a record:
Tconnecting = record
var
a: int64;
b: integer;
c: integer;
end;
which I need send to server using UDP protocol
I fill it
packet.a := StrToInt64('0x1234567890');
packet.b := 0;
packet.c := RandomRange(1, 9999999);
and sending it
SetLength(send_data, sizeof(packet));
send_data := RawToBytes(packet, SizeOf(packet));
udp.SendBuffer(make_it_big_endian(send_data)); <-- the question... "network byte order"
or maybe I’m doing something wrong? I need to send “bign endian” packet
pack("N*", int64, int, int); (this is in PHP)
Thanks.
Assuming your code is running in a little-endian OS/Machine (like Windows/Intel), you can just reverse the individual bytes of your packet, for example, include the FMX.Types unit in your uses clause: