added test for socketstream

This commit is contained in:
Bob Polis
2020-03-17 17:49:16 +01:00
parent 107b09c056
commit 7657226714

View File

@ -22,6 +22,19 @@ int main(int /*argc*/, const char * argv[]) {
sc::io::fdistream is {0};
getline(is, line);
cout << line << '\n';
cout << "starting server\n";
sc::io::socketstream server(AF_INET6, SOCK_STREAM);
sc::io::socket_address addr {"", 4242};
server.make_server(addr);
for (;;) {
sc::io::socketstream client = server.accept();
cerr << "connection from " << client.address() << '\n';
client << "ready to echo...\n";
while (getline(client, line)) {
client << line;
}
}
} catch (const exception& ex) {
cerr << su::basename(argv[0]) << ": " << ex.what() << '\n';
return EXIT_FAILURE;