Today is marks the start of an exciting new project: A P2P Encrypted File Transfer application. I don’t have a creative name for it yet, but I’ll come up with something sooner or later. My goals are
- to learn more about network protocols and encrypted data transfer
- to have a cool project I can show off
- to get out of my coding slump I’ve been on recently lol
Setting up the project
I’m going to use tokio
with Rust because I love using Rust, and because I want to learn more about tokio
. So I set up a new project with cargo
and add the tokio
dependency. I will need a client side and a server side application, so I started with setting up the file system like so:
src
|- bin
|- server.rs
|- client.rs
Now I can run each of them with cargo run --bin server
or client
Server and client side
I started with setting a basic server and client which worked great, and then I modified the code to allow for the client to allow input, and repeated messages to the server! This is was lowkey exciting and now I’m motivated to keep going. Yippee!
Client side cargo run --bin client
Connected to server
Enter a message to send (or type 'exit' to quit):
Hello
Message sent!
Enter a message to send (or type 'exit' to quit):
this is nandu
Message sent!
Enter a message to send (or type 'exit' to quit):
wooooooooooooooo
Message sent!
Server side cargo run --bin server
Server is running on 127.0.0.1:8080
New connection from: 127.0.0.1:53551
Recieved: Hello
Recieved: this is nandu
Recieved: wooooooooooooooo
The code is up on GitHub.
What’s next?
I’m going to undo this little detour I took to allow me to send multiple messages lol, and then I’m gonna start on working with actual file transfer in the next log and maybe even touch on encryption but I don’t want to bite off more than I can chew. That’s it for today! Feeling pumped to tackle file transfers tomorrow, let’s see how far I can take this!