From 376177c76062d58eec1ca46a47fa7e0cea4b8cd7 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Sun, 26 Apr 2020 16:23:32 +0200 Subject: [PATCH] checking for "quit" input from client to close connection --- sciotest/main.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sciotest/main.cpp b/sciotest/main.cpp index 97c93a6..75f811a 100644 --- a/sciotest/main.cpp +++ b/sciotest/main.cpp @@ -49,11 +49,18 @@ void test2() { for (;;) { sc::io::socketstream client = server.accept(); cerr << "connection from " << client.address() << '\n'; - client << "ready to echo...\n"; + client << "ready to echo...\necho> "; string line; while (getline(client, line)) { - cerr << "received: " << line << '\n'; - client << line << '\n'; + cerr << "received: " << line << "\n"; + if (line == "quit\r") { + client << "bye\n"; + client.close(); + break; + } else { + client << line << '\n'; + } + client << "echo> "; } } }