Deadlock with boost::asio::ip::tcp::iostream

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; } } _________________________________________________________________ The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

2010/6/30 Jeff Pai
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.
participants (2)
-
Jeff Pai
-
OvermindDL1