Boost logo

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