Build a TCP server in Go and Rust using standard libraries
Tests standard-library networking APIs in both languages. Strong answer: Go's net.Listen with Accept loop vs Rust's std::net::TcpListener::bind and incoming iterator. Red flag: reaching for HTTP or async frameworks instead of core TCP primitives.
WHAT THIS TESTS: This question checks whether you can name the exact standard-library networking primitives for a bare-metal TCP server in two languages with different concurrency models. Interviewers want to see that you know the boundary between TCP and HTTP, that you understand the listen-accept-handle lifecycle, and that you do not overcomplicate a blocking synchronous task with async runtimes or external crates.
A GOOD ANSWER COVERS: First, in Go, you use the net package. Call net.Listen with the network string tcp and an address like :8080, which returns a net.Listener. Then run a loop calling listener.Accept, which returns a net.Conn and an error. Each connection is usually handled in its own goroutine so the server can accept concurrently. Second, in Rust, you use std::net. Call std::net::TcpListener::bind with an address string, then iterate over listener.incoming or call accept in a loop, which yields a std::net::TcpStream. Because this is the standard library, both approaches are blocking; the key difference is that Go pairs the accept loop with lightweight goroutines while Rust would typically move each TcpStream into a dedicated thread for concurrent handling. Third, mention that you must close or drop connections to avoid leaking file descriptors.
COMMON WRONG ANSWERS: Naming net/http or the http crate shows you are thinking at the wrong layer of abstraction. Proposing Tokio, async-std, or hyper is a red flag because the question explicitly asks for the standard library in both languages. In Rust, confusing std::net::TcpListener with std::os::unix::net::UnixListener is another miss. In Go, forgetting to mention that Accept blocks and returns a Conn is a gap.
LIKELY FOLLOW-UPS: How would you limit the number of concurrent connections? How would you gracefully shut down the server? What is the difference between TcpListener::bind in Rust and net.Listen in Go regarding default address formats? How would you add TLS without changing the overall structure?
ONE CONCRETE EXAMPLE: In Go: listener, err := net.Listen("tcp", ":8080"); for { conn, err := listener.Accept(); go handleConn(conn) }. In Rust: let listener = std::net::TcpListener::bind("0.0.0.0:8080")?; for stream in listener.incoming() { let stream = stream?; std::thread::spawn(move || handle(stream)); }.
Read the original → pkg.go.dev
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.