refactored sock (server-side)