I need to send a buffer of 20 float values through the net using sockets, so they're picked up by another app. I thought I had it by using
private static byte SerializeExact(object anything)
int structsize = Marshal.SizeOf(anything);
IntPtr buffer = Marshal.AllocHGlobal(structsize);
Marshal.StructureToPtr(anything, buffer, false);
var streamdatas = new byte[structsize];
Marshal.Copy(buffer, streamdatas, 0, structsize);
var udpClient = new UdpClient();
byte sendBytes = null;
udpClient.EnableBroadcast = true;
sendBytes = SerializeExact(pack);
but found out it does not work (because a float array is not serializable?), is there any other proper way to do it?
thanks in advance.
View Complete Post