checking for "quit" input from client to close connection
This commit is contained in:
parent
98d3e88872
commit
376177c760
@ -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> ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user