Hazel Networking is an open source, low level networking library for C# providing connection orientated, message based communication via TCP, UDP and RUDP**.** It’s aim is to provide a standardised interface for web communication so that using and switching between protocols is incredibly simple.
Hazel is going to be the basis of DarkRift 2 and I’m releasing it completely open source so that members of the community can make use of it, improve it and help find any bugs before DarkRift 2 is released.
Features
TCP, UDP, Reliable UDP and (at some point) Web Sockets
Completely thread safe
All protocols are connection orientated (similar to TCP) and message based (similar to UDP)
Standardised interface so that all protocols can be used interchangeably with each other
IPv4 and IPv6 support
Continued support as it’s improved and maintained for DarkRift 2
Hazel is now maintained by @ForteBass_1 ! You can find his fork here!
This is perfect Jamie! Having source code to work on will really allow a lot of things to happen from here! I know it’s just a beta, and I’m not expecting, say, exactly the easiness that the original DarkRift provides, but I can really see me working up with this and trying a few things.
One thing I really intend to try now that it is possible to modify the server / client structure is what I mentioned previously (Bluetooth support). I may not be a master of this I guess, but this sure gives me something to work on rather than simple bland solutions and a socket / thread based enviroment
Well, similarly to DarkRift it was never intended to be used peer-to-peer. Bluetooth should be possible though as there’s no NAT to bypass; give it a try!
I always said I’d do a peer-to-peer DarkRift, maybe I’ll get around to that one day…
Ahh, so Hazel is the core you’re building to run darkrift 2 on top of? It’s pretty cool that you shared it, We can do things like have pools of connections (with our own properties) to help out with GC handling etc with this
Yup! That’s the idea!
You can definitely do stuff like that, also check out the Recycle methods on the event argument classes, if you call that it’ll help sort out GC spikes on high usage
Yeah, it is cool
I already provided a wrapper for incoming and outcoming messages. It is pooled and it reuses buffers thanks to Microsoft.IO.RecyclableMemoryStreamManager (take a look at it, if you’re interested).
Now it is time to pool connections and wrap them, so I can proceed with Server and Client classes creation
Just a little advice: I noticed that Hazel targets .NET 4.5. You can’t use it under Unity in this way. I refactored it to target .NET 3.5, but I think I have to rewrite DualMode logic (because Socket.DualMode isn’t allowed in 3.5).
Just come back to this for a bit after a long stretch of development on DarkRift 2, needed a break while I make some crucial design decisions!
Moving to .NET 3.5 is nearly complete, just one Unit Test failing but I’ll hopefully have sorted that by tonight (hopefully). There are a couple of breaking changes but as it’s still technically a beta that’s to be expected; some constructors have changed for the listeners and the IPModes are now IPv4 and IPv6 (as opposed to IPv4 and IPv4AndIPv6) since I’ve temporarily (hopefully) removed dual mode sockets for the downgrade.
After playing with DarkRift for the past few weeks, this is beautifully simple!
There a demo on the quickstart section of the documentation here that talks you through each step and also provides full example code! To do it with UDP is almost exactly the same except you would use UdpClientConnection instead of TcpConnection and UdpConnectionsListener instead of TcpConnectionListener. The API’s for each are the same