fixes issue with wrong assumption about binary protocol

the original implementation thought that "size" would describe the
number of elements in the following array while it in fact desribes the
number of bytes that will be in the following array. so any assumption
about the number of elements would be flawed and lead to too many
itterations ending in EOF reading errors