DarkRiftNetworking / Hazel-Networking

Hazel Networking is a low level networking library for C# providing connection orientated, message based communication via TCP, UDP and RUDP.
http://www.darkriftnetworking.com
MIT License
206 stars 44 forks source link

message order #3

Closed ghost closed 7 years ago

ghost commented 7 years ago

for (int i = 0; i < 100; i++) { connection.SendBytes(Encoding.UTF8.GetBytes("____"+i), SendOption.Reliable); }

recv data like this 10 1 3 4 ____6 ......

ghost commented 7 years ago

send finish callback?

JamJar00 commented 7 years ago

Hi cathy33,

Hazel doesn't provide any guarantees about message order as a side effect of the multithreading it utilises. If ordering was implemented Hazel would need to completely scrap all the advantages the multithreading for ordered packets because otherwise the order could be changed at any time by a thread being disrupted.

If you need order then you could add a prefixing number of bytes to the start and then place the received messages into a priority queue which another thread can read off.

Send finish callbacks can be added, but it would be better if you could create a new issue for that so it can be tracked separately.

Jamie

ghost commented 7 years ago

ok, get it. this library is wonderful for the game dev.

JamJar00 commented 7 years ago

Thanks!

Jamie