fix listener - using read() means we can't be sure to get all the data so we need to loop. it's just like a socket really