So, I know I’m expecting the next thing in my stream (DataStreamReader) to be readable using stream.ReadFixedString64()
Which it is! Works fine, no probs at all. But, how do I know that’s actually what’s in the stream in the first place? Like, what if someone modded the client and is making the server send me an invalid packet? How do I check that the next thing can actually be read using ReadFixedString64? With an integer it’s easy, just check if the remaining stream length at least 4 bytes. But I don’t know the rules for a string, but I do know from testing that the length is variable despite the word “Fixed”.
Or am I meant to check the result of stream.HasFailedReads after I’ve attempted to read the string, and decide how to react from that info? But surely that can’t be the intended approach because that means the client can actually cause error messages in the server by sending invalid packets?
This is something I really want to avoid, because it suggests my server has an error despite that I specifically wrote code to handle invalid packets. Is there some sort of equivalent “bool TryReadFixedString64(out string result)” I could use, so I can decide how to handle invalid packets?