Switch from using tokio, to using the standard library's networking types (TcpStream, UdpSocket) set to non-blocking mode. This provides a number of benefits:
Removes the need for and overhead from channels.
Removes tokio as a dependency.
Allows the errors to be immediately returned from send/recv calls.
Gets rid of an potential issue where sending too many packets per frame would cause a backlog or blocking.
This also is a simpler implementation. There are no async tasks, channels or anything like that.
Potential downsides:
Sending too many packets could block the frame.
Though this also solves the issue of having a que/backlog of packets.
(De)serialization is done on the thread that calls the send/recv method.
This is only a downside when your game/application is single-threaded, and most game/engines will multi-thread for you.
Switch from using tokio, to using the standard library's networking types (
TcpStream
,UdpSocket
) set to non-blocking mode. This provides a number of benefits:Potential downsides: