我有来自二进制形式的 UDP 连接的假设数据。
它由5个字段组成,大小为25位
它们的偏移量如下
1. 0-4 ID
2. 5-10 payload
3. 11-12 status
4. 13-23 location
5. 23-25 checksum
我如何读入这些数据?
DatagramSocket serverSocket = new DatagramSocket(18000);
byte[] receiveData = new byte[1024];
while (true)
{
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
serverSocket.receive(receivePacket);
//not sure how I should be reading the raw binary data back in
}
我将如何存储这些数据?