Socket read/write working, but there are problems with buffers