The exact mechanism to take depends on your environment, programming language, and how you would like it done. The basic idea is to encode the structure or object you want to pass as a bytestream (a step called serialization), then on the other end you simply do the reverse to reconstruct it from the bytestream (deserialization). The variation is whether you want to do the serialization manually in your own format or you entrust this to a library or similar implementing such a mechanism that does that for you.
Say, for Java-Java there is an ObjectOutputStream you can use directly. For C and RPC you can use XDR (
External Data Representation - Wikipedia, the free encyclopedia). Or, you can use XML or JSON that are increasingly popular.