- uint32_t length = sock->read_uint32 ();
- scoped_array<char> buffer (new char[length]);
- sock->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
-
- stringstream s (buffer.get());
- shared_ptr<cxml::Document> xml (new cxml::Document ("ServerAvailable"));
- xml->read_stream (s);
-
- string const ip = sock->socket().remote_endpoint().address().to_string ();
- if (!server_found (ip)) {
- ServerDescription sd (ip, xml->number_child<int> ("Threads"));
+void
+ServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Socket> socket)
+{
+ if (ec) {
+ start_accept ();
+ return;
+ }
+
+ uint32_t length;
+ socket->read (reinterpret_cast<uint8_t*> (&length), sizeof (uint32_t));
+ length = ntohl (length);
+
+ scoped_array<char> buffer (new char[length]);
+ socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
+
+ string s (buffer.get());
+ shared_ptr<cxml::Document> xml (new cxml::Document ("ServerAvailable"));
+ xml->read_string (s);
+
+ string const ip = socket->socket().remote_endpoint().address().to_string ();
+ if (!server_found (ip)) {
+ ServerDescription sd (ip, xml->number_child<int> ("Threads"));
+ {
+ boost::mutex::scoped_lock lm (_mutex);