【发布时间】:2013-08-29 08:43:32
【问题描述】:
我正在为我的 iPhone 制作一个 iOS 套接字客户端。我需要通过 tcp/ip 发送一些字节。一般的想法是,我想将多个值存储在一个字节数组中,以避免多次写入流。举个例子:
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
现在,对于缓冲区数组中的前 4 个位置,我想放置长度变量,从 4 到 13,我想放置实际消息。我知道如何在服务器端对其进行解码,但我不太清楚如何将这些数据放入缓冲区数组中,所以我有一个包含我要发送的所有数据的数组。
非常感谢任何帮助!
【问题讨论】:
标签: objective-c c byte bytearray bytebuffer