checking for "quit" input from client to close connection
This commit is contained in:
parent
98d3e88872
commit
376177c760
@ -49,12 +49,19 @@ void test2() {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
sc::io::socketstream client = server.accept();
|
sc::io::socketstream client = server.accept();
|
||||||
cerr << "connection from " << client.address() << '\n';
|
cerr << "connection from " << client.address() << '\n';
|
||||||
client << "ready to echo...\n";
|
client << "ready to echo...\necho> ";
|
||||||
string line;
|
string line;
|
||||||
while (getline(client, 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 << line << '\n';
|
||||||
}
|
}
|
||||||
|
client << "echo> ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user