I'm making an iOS socket client for my iPhone. I need to send some bytes through tcp/ip. The general idea is, that I want to store multiple values in a single byte array, to avoid several writes to the stream. Take this example:
uint8_t buffer[1024]; // buffer to hold all data I'm sending
NSString *command = @"Broadcast"; // the actual message i want to send
int length = [command length]; // length of said message
Now, for the first 4 positions in the buffer array, i want to put the length variable, and from 4-13, i want to put the actual message. I know how to decode it on the server end, but I can't quite figure out how to get this data into the buffer array, so I have one array with all the data I want to send.
Any help much appreciated!