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
爲標題和用戶分配內存,但我也試圖使緩衝存儲器的連續塊。
我該怎麼做?