added test for socketstream
This commit is contained in:
@ -22,6 +22,19 @@ int main(int /*argc*/, const char * argv[]) {
|
|||||||
sc::io::fdistream is {0};
|
sc::io::fdistream is {0};
|
||||||
getline(is, line);
|
getline(is, line);
|
||||||
cout << line << '\n';
|
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) {
|
} catch (const exception& ex) {
|
||||||
cerr << su::basename(argv[0]) << ": " << ex.what() << '\n';
|
cerr << su::basename(argv[0]) << ": " << ex.what() << '\n';
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
Reference in New Issue
Block a user