Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 1.41 KB

README.md

File metadata and controls

30 lines (18 loc) · 1.41 KB

Tokio TCP Client + Server Basic Example Repo

After a few times of spinning up a similar project layout and writing the boilerplate to setup a server with a tcp connection with framed stream + sink and some kind of shared msg type with a choice of serialization proto, I figured I'd make a repo with this basic project structure all setup to avoid having to do it all again myself.

It may be useful to someone else, because you never know.

This example uses:

  1. Tokio async runtime, net::tcp connection, and channels/sync primitives

  2. Tokio tracing logging library

  3. rmp_serde msgpack for ser/deserialization

You can be easily replace msgpack either with something like bincode or serde_json or you can hand roll your own binary serialization proto if you are feeling spunky.

A basic heartbeat implementation is included, but you'll notice everything is left very intentionally bare because you would likely end up ripping it out anyway if too much more was included here.

This is not meant to be some great example of exactly how to setup or use X or Y. How exactly you structure things like your channels and ownership of different pieces is up to you. However if you think something can be improved, feel free to open a PR, because why not, everything can be improved.