Listing 2

(a)
dti::sockets::tcp_listener tl(123);
dti::sockets::tcpstream ts(tl.accept());
ts << "Hello, client!" << std::endl;
ts << "How are you?" << std::endl;

(b)
dti::sockets::tcp_client_socket s(endpoint("abc.def.com", 123));
dti::sockets::tcpstream ts(s);

char buf[1024];
            
while (ts.getline(buf,sizeof buf))
    std::cout << buf << std::endl;