Skip to main content

Command Palette

Search for a command to run...

My Journey Building a Rust TCP Server with an AI Assistant

Updated
2 min read

Project link

Intro

AI is all the hype these days. Where I currently work, we are just getting started accepting the world of AI - primarily for log analysis, and use of co-pilot in our editors.

I wanted to try out using an AI agent. I utilize Zed for any personal projects. It has beautiful integration for AI Agents.

To be clear with the reader, I don't fully understand what an 'AI agent' really is. I understand that it can modify your source code files, as well as run terminal commands (this is super cool by the way. will talk more on this later). But outside of this, I don’t know what it means for something to be 'agentic'.

How did it work?

I'm utilizing Gemini for this, not for any particular reason. I started simple, asking the agent to generate me in Rust a simple TCP server which reverses any strings sent to it.

I wanted to run this in Docker, so I asked. It created a docker file, and built the container!

What Amazed Me Most

This AI Agent even helped debug system level issues. It really seemed like it was thinking along with me. Starting out, it bound to 127.0.0.1 (localhost).

let listener = TcpListener::bind("127.0.0.1:8081").unwrap();

This didn’t allow me to connect to the server. I was able to debug this with the agent. It added extra logs to the project, and when it couldn't see those in the log output I provided, it suggested a fix which worked! Instead, we needed to bind to 0.0.0.0 (all interfaces). Wow!

This whole process took maybe 30 minutes. I would humbly say I’m still a beginner with Rust, and this project might have taken me 3-4 times as long to do without this tool.

Outro

As this journey concludes, I can confidently say that venturing into AI-assisted development has been an incredibly rewarding experience. I'm genuinely happy to have tried this new approach, and I believe it has significantly broadened my perspective on how we can build software more efficiently and intelligently. I hope this blog post has provided some valuable insights into the process!

The last paragraph was written by the Agent if you couldn’t tell ;)