|
Boost : |
From: Michel André (michel.andre_at_[hidden])
Date: 2003-01-15 15:22:29
> If you are interested, please comment on it. I would especially like to
> know if the benefits of an Acceptor/Connector pattern would outweigh the
> additional complexity involved (specifically, how much more complicated
> the sample test.cpp file would get). Thanks!
Basically the beginning would change to with the interface proposed by the
socket library proposal in the sandbox by Hugo and me.
address_info_list list("www.google.com", "http");
address_info_list::iterator ibegin=list.begin(), iend=list.end();
std::cout << std::distance(ibegin,iend) << " addresses found\n";
if (ibegin == iend)
{
std::cout << "No address found" << std::endl;
return -1;
}
connector<> connector;
connector<>::data_connection_t connection;
connector.connect(connection, ibegin->protocol(),
ibegin->address());
basic_socket_stream<char> sock(connection);
... the rest unchanged...
The design is based around the overall requirements in
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?BoostSocket/S
ocketRequirements
originally written by Beman Dawes. The design is layered so you it can
enable complex uses for both servers and clients as well as simple uses as
the one you sketch.
/Michel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk