Remote: read now retry when it did not get all the expected data

This commit is contained in:
Maxime Coste 2012-11-19 19:07:32 +01:00
parent fe98ba7494
commit 1602fcf012

View File

@ -89,12 +89,17 @@ void write(Message& msg, const DisplayBuffer& display_buffer)
void read(int socket, char* buffer, size_t size) void read(int socket, char* buffer, size_t size)
{ {
int res = ::read(socket, buffer, size); while (size)
if (res == 0) {
throw peer_disconnected{}; int res = ::read(socket, buffer, size);
if (res == -1) if (res == 0)
throw socket_error{}; throw peer_disconnected{};
assert(res == size); if (res < 0)
throw socket_error{};
buffer += res;
size -= res;
}
} }
template<typename T> template<typename T>