stage 2 attempt 1

This commit is contained in:
YK 2024-05-10 20:26:28 +03:00
parent e05e736244
commit 42d28e91c0

View File

@ -1,18 +1,14 @@
// Uncomment this block to pass the first stage use std::{ io::Write, net::TcpListener };
use std::net::TcpListener;
fn main() { fn main() {
// You can use print statements as follows for debugging, they'll be visible when running tests.
println!("Logs from your program will appear here!");
// Uncomment this block to pass the first stage
//
let listener = TcpListener::bind("127.0.0.1:4221").unwrap(); let listener = TcpListener::bind("127.0.0.1:4221").unwrap();
for stream in listener.incoming() { for stream in listener.incoming() {
match stream { match stream {
Ok(_stream) => { Ok(mut stream) => {
println!("accepted new connection"); println!("accepted new connection");
let _200 = b"HTTP/1.1 200 OK\r\n\r\n";
let _ = stream.write(_200);
} }
Err(e) => { Err(e) => {
println!("error: {}", e); println!("error: {}", e);