Support reading strings more that 2048 bytes

fixes #95
This commit is contained in:
Maxime Coste 2014-04-23 22:21:04 +01:00
parent 389308dfd8
commit 418a04f49d

View File

@ -158,12 +158,13 @@ template<>
String read<String>(int socket) String read<String>(int socket)
{ {
ByteCount length = read<ByteCount>(socket); ByteCount length = read<ByteCount>(socket);
if (length == 0) String res;
return String{}; if (length > 0)
char buffer[2048]; {
kak_assert(length < 2048); res.resize((int)length);
read(socket, buffer, (int)length); read(socket, &res[0], (int)length);
return String(buffer, buffer+(int)length); }
return res;
} }
template<typename T> template<typename T>