protected static function exceptionOnFalse($resource, callable $closure)
    {
        $result = $closure($resource);

        if ($result === false) {
            throw new SocketException($resource);
        }

        return $result;
    }