Correctly sending and receiving a struct through Indy UDP
问题 Consider the following minimal program using Borland 2007 and Indy UDP server and client: struct DATA_PACKAGE { int t; int x; int y; }; void __fastcall TForm1::Button1Click(TObject *Sender) { DATA_PACKAGE a; a.t = 3; a.x = 2; a.y = 1; Form1->Memo1->Lines->Add("sent " + IntToStr(sizeof(DATA_PACKAGE))); Form1->UDPClient1->SendBuffer(server,port,RawToBytes(&a, sizeof(DATA_PACKAGE))); } void __fastcall TForm1::UDPServer1UDPRead(TObject *Sender, TBytes AData, TIdSocketHandle *ABinding) { DATA