There are several ways to do this. You may be able to play with marshaling attributes such as StructLayout to pack the structure into an array of bytes, but this is probably complicated and not worth the effort.
You can use a specialized structure such as Protobuf to assign a class so that it is serialized according to the structure you need.
But, in my experience, the easiest, fastest, and most flexible way to create such a binary structure is to use the MemoryStream class to store the fraction buffer, and then use the BinaryWriter around it to actually write the binary data to the stream.
In any case, it helps to have a working server for the link. Use a tool like Wireshark or Microsoft Network Monitor to capture wired traffic so you can compare your wire format with an example that is known to work.
source share