readLengthPrefix static method
Reads a 4-byte big-endian length prefix from the stream.
Implementation
static Future<int> readLengthPrefix(P2PStream stream) async {
final lengthBytes = await readExactly(stream, 4);
return ByteData.sublistView(lengthBytes).getUint32(0);
}