sockread -fn 4096 %x.src

You are not reading into a binary variable for a start, thats got to cause problems.