Hello
Figured out the second part. Your code writes:
write(7, "\0\0\0\0\5\0\0\0", 8) = 8
write(7, "\0\0\0\0\1\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0*\0\0\0"...,
40) = 40
Then ReadFromStream reads with CopyN, which does:
read(5, "\0\0\0\0", 4) = 4
# at this point, the next 4 bytes of the first packet go missing
read(5, "\0\0\0\0", 4) = 4
Now you read a bunch of zeros from the second packet, which just
happens to make ReadFromStream think that your message is empty.
The other problem with UDP is that your messages could arrive out of
order, which will also break your stream.
So for UDP, definitely serialise to a buffer first and send that to
the socket with a single Write call.
I'll look into the packed issue a bit later.
Regards
Albert