Hello everyone,
I've been fiddling with UDP sockets in Rust within the past two months with the hope of creating something stable to use for a multiplayer game. Though I was able to write a functionally bare UDP server and client, I realized I needed more than just the ability to send and receive packets. I went through several iterations, once using mioco to circumvent blocking, and another separate attempt at UDP reliability (based on this).
After all this, I came to the conclusion that what I had written so far would be incomplete, missing vital features like reliability and ordering. Given that this was something I would want to release to the community eventually, I wanted to ensure that it could be suitable for other projects. This is when I remembered libenet, which is a popular C/C++ networking library for applications.
ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol).The primary feature it provides is optional reliable, in-order delivery of packets.
ENet omits certain higher level networking features such as authentication, lobbying, server discovery, encryption, or other similar tasks that are particularly application specific so that the library remains flexible, portable, and easily embeddable.
Their design and implementation has mileage so I think it would be a good option to port over to Rust. I know there exists bindings to this library, but its usage is unsafe, one thing I am trying to avoid. Since safety is at the core of Rust, I am hoping to keep that mantra in mind. I do not think there is anything out there right now which provides what I (and many others might) want.
So I've decided to take a stab at it myself. I don't have any real networking programming experience besides the sandboxing I mentioned above, and I've only begun to wet my feet in Rust recently. In essence I'm a few scratch marks on a tabula rasa.
Something that popped into my head was tokio
but I'm not sure if it'd apply or how it would be used to be quite frank. I saw this post on Reddit today which gives a good intro it tokio with a TCP Server in mind. But again, I'm not sure if this is something I'd want to consider for the port.
I am hoping I am not biting off more than I can chew. I was wondering if any of my fellow rustaceans had any ideas or tips (even warnings) before I go about doing this.
Thanks,
Manghi