|
Boost Users : |
Subject: Re: [Boost-users] Deadlock with boost::asio::ip::tcp::iostreamâ
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-07-04 23:09:01
2010/6/30 Jeff Pai <irishbam_at_[hidden]>:
> Hi everyone,
> I took the daytime example and add a request this iostream, and it starts
> deadlocking in windows environment. Is this the wrong way to do it?
>
> int main(int argc, char* argv[])
> {
> try
> {
> if (argc != 2)
> {
> std::cerr << "Usage: daytime_client <host>" << std::endl;
> return 1;
> }
>
> tcp::iostream s(argv[1], "daytime");
> s << "request";
> std::string line;
> std::getline(s, line);
> std::cout << line << std::endl;
> }
> catch (std::exception& e)
> {
> std::cout << "Exception: " << e.what() << std::endl;
> }
>
> return 0;
> }
>
> void server()
> {
> Â try
> Â {
> Â Â Â boost::asio::io_service io_service;
>
> Â Â Â tcp::endpoint endpoint(tcp::v4(), 13);
> Â Â Â tcp::acceptor acceptor(io_service, endpoint);
>
> Â Â Â for (;;)
> Â Â Â {
> Â Â Â Â Â tcp::iostream stream;
> Â Â Â Â Â acceptor.accept(*stream.rdbuf());
> Â Â Â Â Â std::string req;
> Â Â Â Â Â stream >> req;
> Â Â Â Â Â stream << make_daytime_string();
> Â Â Â }
> Â }
> Â catch (std::exception& e)
> Â {
> Â Â Â std::cerr << e.what() << std::endl;
> Â }
> }
You should post this to the AISO list (I did so, you should join that
list so you can see the responses), there is a chance it could be
related to a bug I just posted on that list, even if it is not, they
can help better there.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net