lemunozm / message-io

Fast and easy-to-use event-driven network library.
Apache License 2.0
1.12k stars 75 forks source link

How to support transport protocols that are not in mio? #64

Closed NOBLES5E closed 3 years ago

NOBLES5E commented 3 years ago

For example RDMA. Thanks!

lemunozm commented 3 years ago

Hi @NOBLES5E,

"that are not in mio" can be ambiguous because mio has an interface that allows you to use "whatever" you want. It's true that mio comes with few protocols already prepared to use, but if you implement from Source trait you can make your own protocol works with mio. To make a message-io adapter the only required from mio is that you return this Source. An example of that is the Websocket adapter, which uses a library that has nothing to do with mio (tungstenite-rs).

Having said that, I do not know about RDMA (Only the fast search I made 😄), and I can not see clearly the implications to use it with message-io. Do you know about some rust library that implements RDMA?

NOBLES5E commented 3 years ago

Thanks for your reply! Recently I am thinking about writing software in Rust supporting RDMA (which could improve network performance a lot in many scenarios), and I am still in my first step to collect related information. There are libraries like https://github.com/jonhoo/rust-ibverbs. I also created an issue for tokio here: https://github.com/tokio-rs/tokio/issues/3637.

lemunozm commented 3 years ago

That sounds amazing! 😃

I was investigating a little bit about implementing your own protocol based on mio and I retract to myself: you can implement the Source trait only if you are using underlying something already Sourceable, this "recursion" ends when you are able to register the file descriptor in the poll (and so the poll can wake up based on the OS event over this file descriptor). Maybe only if you can access this file descriptor, then you could create a non-blocking resource for your protocol based on mio that others can use in their projects (as in tokio or message-io! 😋).

So, to summarize: If your protocol is based on TCP, UDP, UDS or uses a file descriptor, you should be able to implement it to works in a non-blocking mode with mio (and therefore you could make also an adapter for message-io*).