Remote: read now retry when it did not get all the expected data
This commit is contained in:
parent
fe98ba7494
commit
1602fcf012
|
@ -88,13 +88,18 @@ 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)
|
||||||
|
{
|
||||||
|
while (size)
|
||||||
{
|
{
|
||||||
int res = ::read(socket, buffer, size);
|
int res = ::read(socket, buffer, size);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
throw peer_disconnected{};
|
throw peer_disconnected{};
|
||||||
if (res == -1)
|
if (res < 0)
|
||||||
throw socket_error{};
|
throw socket_error{};
|
||||||
assert(res == size);
|
|
||||||
|
buffer += res;
|
||||||
|
size -= res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user