// // main.cpp // sciotest // // Created by Bob Polis at 2020-02-14 // Copyright (c) 2020 SwiftCoder. All rights reserved. // #include #include #include #include using namespace std; int main(int /*argc*/, const char * argv[]) { try { sc::io::fdostream chan {1}; chan << "Please enter a line of text:\n"; string line; 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; } return EXIT_SUCCESS; }