develop nc clone in rust #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
develop nc clone in rust
Implementation Spec for Issue #1
Objective
Develop a minimal, functional command-line utility in Rust that mimics basic
nc(netcat) functionality, supporting TCP/UDP client/server modes, and bidirectional data streaming between stdin/stdout and network sockets.Requirements
clapfor robust argument handling-l,--listen)-u,--udp)Files to Create
Cargo.toml- Project metadata and dependencies (clap,tokio)src/main.rs- Main entry point and CLI argument parsingsrc/args.rs- Definition of CLI arguments usingclapsrc/network.rs- Logic for handling TCP/UDP connections and data streamingImplementation Plan
Step 1: Project Initialization
Files:
Cargo.tomltokio(full features) andclap(derive feature)Dependencies: none
Step 2: Define CLI Arguments
Files:
src/args.rsclap::Parserwith host (optional string), port (u16), -l flag (listen), -u flag (UDP)Dependencies: Step 1
Step 3: Implement TCP Client/Server Logic
Files:
src/network.rstokio::net::TcpStreamtokio::net::TcpListenerDependencies: Step 1
Step 4: Implement UDP Logic
Files:
src/network.rstokio::net::UdpSocketDependencies: Step 3
Step 5: Implement Bidirectional Streaming
Files:
src/network.rstokio::io::copy_bidirectionalto bridge stdin/stdout with network streamDependencies: Step 4
Step 6: Integration and Error Handling
Files:
src/main.rsDependencies: Step 2, Step 5
Acceptance Criteria
cargo buildcompiles without errorsncrust -l 8080and connect viatelnet localhost 8080ncrust localhost 8080to connect to an existing server-uflag correctly switches the protocol to UDPNotes
connecton the UDP socket to simplifyTest Results
ncrustcompiled successfullyManual verification steps:
cargo buildcompiles without errorsImplementation Summary
Files Created
Cargo.toml- Project configuration with tokio and clap dependenciessrc/main.rs- Entry point with tokio runtime and CLI parsingsrc/args.rs- CLI argument definitions (host, port, -l, -u flags)src/network.rs- TCP/UDP client/server networking logicFeatures Implemented
Build
cargo buildcompiles successfully with no errorsncrustUsage
Notes