Fixed reading and writing from the socket
Merge pull request #33 from thehydroimpulse/refactor

Fixed reading and writing from the socket