jgauffin / griffin.networking

Networking library for .NET
http://blog.gauffin.org/2012/05/griffin-networking-a-somewhat-performant-networking-library-for-net/
GNU Lesser General Public License v3.0
108 stars 35 forks source link

Message Framing Fails When Sending Data Quickly #15

Open AlexArchive opened 11 years ago

AlexArchive commented 11 years ago

When receiving a lot of messages from a client application in quick succession: The server will throw one of the following exceptions:

Invalid Data Version (your validation) Message Length Negative (your validation) Some Serialization Issue (due to invalid stream of bytes) (BinaryFormatter)

The problem is that when sending a lot of messages very quickly the message framing messes up. The bytes are received in the wrong order.

The exception thrown depends on "luck" really if what the client perceives to be the length prefix is converted to a positive integer, the message length negative exception will not be thrown; else, it is.