LNET UDP send data stream problem lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- MaartenJB · 2015-06-14 09:53 Hi, I've got a problem sending udp data from a stream with lnet udp. I've made two examples, the first one is just sending an integer, which works just fine. In the second one I place the Integer inside a stream, when I send it, the data is not correct. (examening packets with wireshark packet sniffer) Working code: Code: [Select]var   TestInt : Integer;   sHost : String; begin   sHost := '169.254.8.237';   TestInt := 123456789;   udpServer.Connect(sHost, 8888);   udpServer.Send(TestInt, SizeOf(Integer), sHost);   udpServer.Disconnect(False); end; Not working: Code: [Select]var   TestInt : Integer;   sHost : String;   TestStream : TMemoryStream; begin   sHost := '169.254.8.237';   TestInt := 123456789;   TestStream := TMemoryStream.Create;   try     TestStream.WriteBuffer(TestInt, SizeOf(Integer));     TestStream.Position:=0;     udpServer.Connect(sHost, 8888);     udpServer.Send(TestStream, TestStream.Size, sHost);     udpServer.Disconnect(False); //    TestStream.SaveToFile('abc.bin'); // when I look in this saved file, the data is fine   finally     TestStream.Free;   end; end;  Do I need to do something else when sending a stream? Thanks in advance, Maarten ---------------------------------------------------------------------- benohb · 2015-06-15 15:04 TestStream is class .... not data Code: [Select]TestStream.Memory is pointer to first byte of data Code: [Select]udpServer.Send(TestStream.Memory, TestStream.Size, sHost); Check  Code: [Select]writeln(Integer(TestStream.Memory^))TestStream.Position:=10;; The result is TestInt Value + TestStream.Position:=0; not needed ---------------------------------------------------------------------- MaartenJB · 2015-06-15 19:20 Hi benohb, Thanks for that valuable lesson! It's working now  (I need to use the ^ sign when using udp.send() aswell, like the writeln() example) Thanks again!