Sockets secure implementations

Rebased on `master`.
Nit: Use newer&nicer syntax:   = _sockets[socketId];