Fixed socket writer/reader encryption.
Merge pull request #881 from mdogan/fix/3.0/encryption

Fixed and improved socket writer/reader encryption.