From 5a9c0c9a6c774bd9670b8fab8a1cce84c497516c Mon Sep 17 00:00:00 2001 From: omagdy Date: Tue, 15 Jul 2025 01:23:54 +0300 Subject: codecrafters submit [skip ci] --- codecrafters.yml | 2 +- src/main.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/codecrafters.yml b/codecrafters.yml index 83a3898..99234a0 100644 --- a/codecrafters.yml +++ b/codecrafters.yml @@ -2,7 +2,7 @@ # # These can be VERY verbose, so we suggest turning them off # unless you really need them. -debug: false +debug: true # Use this to change the Rust version used to run your code # on Codecrafters. diff --git a/src/main.rs b/src/main.rs index 464716f..5c89f41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,11 +10,10 @@ fn main() { for stream in listener.incoming() { match stream { Ok(mut stream) => { - let mut buf = [0; 128]; - stream.read(&mut buf).unwrap(); - let request = str::from_utf8(&buf).unwrap(); - for _ in 0..request.matches("PING").count() { - stream.write_all(b"+PONG\r\n").unwrap(); + let mut buf = [0; 512]; + loop { + let _ = stream.read(&mut buf).unwrap(); + stream.write(b"+PONG\r\n").unwrap(); } } Err(e) => { -- cgit v1.2.3