From 7657226714408dc69370aa05f51e93fe9d5ed54b Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Tue, 17 Mar 2020 17:49:16 +0100 Subject: [PATCH] added test for socketstream --- sciotest/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sciotest/main.cpp b/sciotest/main.cpp index da9ec70..a28d80e 100644 --- a/sciotest/main.cpp +++ b/sciotest/main.cpp @@ -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;