checking for "quit" input from client to close connection

This commit is contained in:
Bob Polis 2020-04-26 16:23:32 +02:00
parent 98d3e88872
commit 376177c760

View File

@ -49,12 +49,19 @@ 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';
cerr << "received: " << line << "\n";
if (line == "quit\r") {
client << "bye\n";
client.close();
break;
} else {
client << line << '\n';
}
client << "echo> ";
}
}
}