Socket wrapper for server/client connections, with encryption support.