b23r0 / rust-raknet

RakNet Protocol implementation by Rust.
MIT License
218 stars 18 forks source link

The README claims to be async,, but socket does not implement `AsyncRead` neither `AsyncWrite` #4

Closed feelingnothing closed 2 years ago

feelingnothing commented 2 years ago

To use this socket within codecs in tokio utility crate, the socket must implement AsyncRead and AsyncWrite. Is this possible to implement?

b23r0 commented 2 years ago

I may implement the two traits AsyncRead and AsyncWrite in the next version. If you are interested in participating in the development, you can also submit a PR for your needs.

feelingnothing commented 2 years ago

Cool, waiting for new release, I guess I don't even have to wait for release on crate.io because I already use git dependency due to strange hivemc raknet implementation. Hope for the fast fix for this, because I can't see the point of using it without Async[Read|Write] because all async api's require these traits anyways for comfortable usage. I like how codecs work in tokio-util, but this issue really stopping me from using library

b23r0 commented 2 years ago

I have committed AsyncRead and AsyncWrite support for RaknetSocket in the main branch. I will officially release it to crates.io in the next version. You can already test it by integrating the git repository. If you have any problems, you can continue to file an issue. If there are no problems I will close this issue in the near future.

b23r0 commented 2 years ago

A note on some AsyncRead implementations.

/// Note: AsyncRead requires you to provide a fixed-size buffer for reading data.
/// 
/// However, Raknet is not a streaming protocol, so when you use AsyncRead, if you don't provide enough buffer size (less than Raknet Packet size), then a Raknet Packet will be split into multiple reads.
/// 
/// This will lead to a similar TCP unpacking problem when you use AsyncRead when you are developing scenarios such as Raknet reverse proxy where the packet size cannot be predicted.
/// https://programmer.ink/think/tcp-packet-sticking-unpacking.html
/// So it is not recommended to use AsyncRead for developing Raknet reverse proxy.
///