As Richard noted, the problem could be in any other part of your code. So you are alone on this as we cannot guess what may be happening there.
However, the part you posted does not somehow checks for valid incoming message. For example you could on the sending device use a string of "hey" and then the data.
On the receiving device wait("hey") and then collect your data. In this case you will not receive data in the middle of the transmission.
Ioannis
Bookmarks