Sockets secure implementations

Rebased on `master`.
why send it three times? add a comment and make each one log a different message.