From 7a59e1ce77c7cef3714127dbce46b84c9f94963f Mon Sep 17 00:00:00 2001 From: "Simon V. Lejel" Date: Sat, 10 Feb 2024 14:40:58 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Close=20server=20when=20client?= =?UTF-8?q?=20leaves?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/main.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/server/main.cc b/src/server/main.cc index 1232f6c..52207c6 100644 --- a/src/server/main.cc +++ b/src/server/main.cc @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -39,6 +40,12 @@ int main() { while (true) { char buffer[1024] = {0}; recv(clientSocket, buffer, sizeof(buffer), 0); + + if (strlen(buffer) <= 0) { + cout << "Client seems to have just straight up left :(" << endl; + break; + } + cout << buffer << endl; }