Sockets secure implementations

Rebased on `master`.
nit: add a comment saying why we need to call setPaused here