*/
-#include "encode_server_finder.h"
-#include "exceptions.h"
-#include "util.h"
#include "config.h"
+#include "constants.h"
#include "cross.h"
-#include "encode_server_description.h"
#include "dcpomatic_socket.h"
+#include "encode_server_description.h"
+#include "encode_server_finder.h"
+#include "exceptions.h"
#include <dcp/raw_convert.h>
#include <libcxml/cxml.h>
#include <boost/bind/placeholders.hpp>
return;
}
- uint32_t length;
- _accept_socket->read (reinterpret_cast<uint8_t*>(&length), sizeof(uint32_t));
- length = ntohl (length);
+ string server_available;
- scoped_array<char> buffer(new char[length]);
- _accept_socket->read (reinterpret_cast<uint8_t*>(buffer.get()), length);
+ try {
+ uint32_t length;
+ _accept_socket->read (reinterpret_cast<uint8_t*>(&length), sizeof(uint32_t));
+ length = ntohl (length);
+
+ scoped_array<char> buffer(new char[length]);
+ _accept_socket->read (reinterpret_cast<uint8_t*>(buffer.get()), length);
+ server_available = buffer.get();
+ } catch (NetworkError&) {
+ /* Maybe the server went away; let's just try again */
+ start_accept();
+ return;
+ }
- string s (buffer.get());
auto xml = make_shared<cxml::Document>("ServerAvailable");
- xml->read_string (s);
+ xml->read_string(server_available);
auto const ip = _accept_socket->socket().remote_endpoint().address().to_string();
bool changed = false;