Skip to content

Extend tcp_echo #189

@sysheap

Description

@sysheap

tcp_echo currently accepts one connection, echoes data until EOF, then exits. It should serve multiple concurrent connections by spawning a new OS thread per accepted connection.

Current state

  • Program: userspace/src/bin/tcp_echo.rs
  • Listens on port 1234, calls listener.accept() once, echoes in a loop, then exits.
  • System test: system-tests/src/tests/net.rs::tcp_echo — opens one connection and verifies two round-trip messages.

Required changes

userspace/src/bin/tcp_echo.rs

Change the main loop to:

  1. Call listener.accept() in a loop.
  2. For each accepted connection, spawn a new OS thread (via std::thread::spawn) to handle it.
  3. The per-connection thread reads until EOF and echoes back each chunk, then exits.

The program should keep running indefinitely (it is a server), so the main thread only loops on accept.

New system test

Add a test tcp_echo_concurrent in system-tests/src/tests/net.rs that:

  1. Starts Solaya with networking and launches tcp_echo.
  2. Opens 20 simultaneous TCP connections from the test host.
  3. Sends a unique message on each connection concurrently (use tokio::join! or FuturesUnordered).
  4. Asserts that each connection receives its own message back.
  5. Closes all connections.

Acceptance criteria

  • cargo nextest run --release --manifest-path system-tests/Cargo.toml --target x86_64-unknown-linux-gnu tcp_echo passes (existing single-connection test).
  • New tcp_echo_concurrent test passes with all 20 connections getting correct echo replies.
  • No kernel panic under the concurrent load.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions