The fact that it comes in parts is meaningless and has nothing to do with freezing anything. If you know what you expect then you can wait until your expectations are filled. Doing this by ignoring the data is probably not the best idea but it is possible. A better way is to read the pending data (thus freeing the incoming buffer), scanning that data for end of message (which is easy in your case) and either processing the data or waiting until more comes in. Remember that you can also get more than one message in a single go, you need to handle situations like that as well.
Bookmarks