Implementing protected sockets