1
我需要转移在网络中的缓冲液中,其中包含以下:如何使用C++通过网络传输缓冲区?
- 2个字节,其保持总缓冲器大小
- 2个字节,其保持标头的大小
- 部首
- 实际用户消息
这是我所限定的缓冲液:
class Buffer
{
public:
Buffer(size_t Capacity);
private:
uint8_t totalSize[2];
uint8_t headerSize[2];
uint16_t header[???]; // incorrect
uint8_t user[Capacity];
};
我想要做的就是喜欢的东西send(reinterpret_cast<unsigned*>(&buffer))
送Buffer
一个实例。
我知道我可以使用new
为标题和用户分配内存,但我也试图使缓冲存储器的连续块。
我该怎么做?