Hazel Networking - Open Source RUDP/TCP Library

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!

Jamie (your friendly DarkRift person!)

Updates
Update 17/07/16 - Now built for .NET 3.5, remade IPv6 support to fit.
Update 27/09/16 - TCP bug fixes.
Update 14/11/16 - Security patch and added the ability to send data with connection message.
Update 18/11/16 - Unity UDP bug fixes.
Update 30/11/16 - Connect timeout
Update 31/12/16 - Fragmented Messages
Update 03/01/17 - Fixed incorrect timeout values
Update 31/01/17 - UDP Disconnection fix
[Update 31/10/17]( Hazel Networking - Open Source RUDP/TCP Library page-2#post-3272190) - Compilation fix and bug fixes

6 Likes

Forked!
I’ll give it a shot in few days!
Keep up the good work! :smile:

1 Like

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 :slight_smile:

Thank you for this! i’m really glad to see it!

1 Like

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! :slight_smile:

I always said I’d do a peer-to-peer DarkRift, maybe I’ll get around to that one day…

1 Like

Just updated with bug fixes, improvements and also the resend timeout for RUDP is now based of the average ping :slight_smile:

1 Like

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 :slight_smile:

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 :slight_smile:

Yeah, it is cool :smile:
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 :smile:

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).

1 Like

Nice!

Ahh yeah I need to sort that, there’s a socket option that you can set instead.

1 Like

Yeah, you can do something like that:

socket.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27, false);

Anyway, I think I will wait for DarkRift 2 instead of roll my own solution based on Hazel.
I tried the APIs and I like it :smile:

1 Like

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! :slight_smile:

EDIT: Nope… Now it wont connect… :eyes:

Jamie

1 Like

looks interesting can you make a small demo ability to send udp packets also tcp

Hey!

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 :slight_smile:

i dont have experience in c# out side unity i will try to make it working

Update 0.1
Hazel now supports .NET 3.5!

The latest build is available from GitHub here!

2 Likes

Dropping a comment to stay up to date! Great work so far, Jam!

1 Like

Hi, Hazel looks cool, i’m using it for my new game now, seems Web Sockets is not supported yet?

1 Like

Not yet sorry! I’ve been so busy working on DarkRift 2 I forgot about them!

H Jamster, Hazel Networking is very easy to use, i like it. Thanks for share, is it still in maintain as a part of DarkRift 2?

I have no plans to discontinue Hazel Networking :slight_smile: It’ll be maintained as long as I’m still maintaining DarkRift 2, possibly longer :slight_smile: