So, I'm trying to learn some networking with tokio. I'm having a really hard time with the abstractions used and what's worse the documentation is not really there right now.
Here's my current problem:
I'm trying to do something pretty simple: I have a server that acts as a dumb database. It gets send a Vec, stores it in a HashMap and should send back a id for future retrival. The client can send that data and later retrieve it with the received Id.
Later I would like to be able to be able to deserialize that data with serde on the client side (the server doesn't really need to know what is being stored).
Each package the has the following format:
+===============+==================+============+==============+==================+
| msg_size: u64 | request_type: u8 | has_id: u8 | id: [u8; 16] | content: Vec<u8> |
+===============+==================+============+==============+==================+
ps: yes, this message pack could be better optimized and stuff, but this is just a proof of concept.
My client/server code is here (the client carries a T generic parameter so I can work with serde later on)
When I try to use this code as a client the connection seems to never be established (the server never prints that something arrived). What's interesting though is that I never get an error and when I stop the application (using C^) the server does receive b"".
I'm pretty sure my client part of the code is wrong and I would like some help with fixing it.
Anyway, the second part of my problem is with the server itself. If I use this code as a client the server seems to receive packages nonstop. It keeps printing the it received something even though I only sent the package once. What gives?
Thanks in advance. Also, is there any good intro to tokio with more then simple "ping pong" examples? The examples I find are either too simple (ping pong, echo) or too complex (an http-server). It would be nice to have something in between properly explaining how to work with all the abstractions...