What you want to reearch is
Data Marshalling[
^] and its close cousin
Serialization[
^]. These are common tasks in computing.
The main point is that if your struct/class just contains
fundamental data types[
^] and no pointers, just send it across the wire without conversion and read "as is" on the other side (you will need a cast to read in enum values). If it contains pointers you will have to dereference the pointer and send that info.