You need to only process the buffer when you have received the whole tag, and clear the buffer once you have processed it. This means you need a way to detect the start and end of the tag.
You need to only process the buffer when you have received the whole tag, and clear the buffer once you have processed it. This means you need a way to detect the start and end of the tag.