socket: refactor protocols