protected function processClientSocket($socket): void
    {
        $connection = $this->getConnectionForClientSocket($socket);

        if (!$connection) {
            $this->logger->warning('No connection for client socket');
            return;
        }

        try {
            $this->server->notify(Server::EVENT_CLIENT_DATA, [$socket, $connection]);

            $connection->process();
        } catch (CloseException $e) {
            $this->logger->notice('Client connection closed: {exception}', [
                'exception' => $e,
            ]);
            $connection->close(Protocol::CLOSE_UNEXPECTED, $e->getMessage());
        } catch (WrenchException $e) {
            $this->logger->warning('Error on client socket: {exception}', [
                'exception' => $e,
            ]);
            $connection->close(Protocol::CLOSE_UNEXPECTED);
        } catch (InvalidArgumentException $e) {
            $this->logger->warning('Wrong input arguments: {exception}', [
                'exception' => $e,
            ]);
            $connection->close(Protocol::CLOSE_UNEXPECTED);
        }
    }