Continuing about communication errors...
AS I said, there are some types of errors: timeout, packet splitting and buffer overflow. Some methods used to evade timeout errors are usefull and for solving packet splitting errors.
If you send some type of data in all piece, not always data comes to end point in one piece. Often occurs some delay in middle of packet. Packet received often means, some data has been gotten, but not necessary all data. Packet start and end characters, whereas data packet length is helpful for determining where is packet end.
Packet splitting errors only occur in receiving end. Simple and effective algorithm of data receiving and processing can be used in receiving part, as follows:
1. For every new connection, create new free buffer, if it is a reconnection, use old buffer.
2. When data is received, all data should be added to the end off additional buffer.
3. Constantly check buffer, if it contains correct data. It's good to check for start, end characters, length and integrity.
4. Remove and precess data, passed step 3 from start of the buffer.
For single communication, it's simple to buffer data. In multicommunication, there are some challenges to distribute data in buffer. But, there are methods and for that, like network packet always has sender and receiver ip and mac addresses, and that information can be used to distribute data in buffer.