当前位置: 首页>>代码示例>>C++>>正文


C++ StreamBuffer::device方法代码示例

本文整理汇总了C++中StreamBuffer::device方法的典型用法代码示例。如果您正苦于以下问题:C++ StreamBuffer::device方法的具体用法?C++ StreamBuffer::device怎么用?C++ StreamBuffer::device使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StreamBuffer的用法示例。


在下文中一共展示了StreamBuffer::device方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onInput

void Socket::onInput(StreamBuffer& sb)
{
    log_debug("onInput");

    sb.endRead();

    if (sb.in_avail() == 0 || sb.device()->eof())
    {
        close();
        return;
    }

    while (sb.in_avail() > 0)
    {
        if (_responder.advance(sb.sbumpc()))
        {
            _responder.finalize(_stream);
            buffer().beginWrite();
            onOutput(sb);
            return;
        }
    }

    sb.beginRead();

}
开发者ID:acklinr,项目名称:cxxtools,代码行数:26,代码来源:socket.cpp

示例2: onInput

void ClientImpl::onInput(StreamBuffer& sb)
{
    try
    {
        try
        {
            log_trace("ClientImpl::onInput; readHeader=" << _readHeader);

            _errorPending = false;

            sb.endRead();

            if (sb.device()->eof())
                throw IOError("end of input");

            _reconnectOnError = false;

            if (_readHeader)
            {
                processHeaderAvailable(sb);
            }
            else
            {
                processBodyAvailable(sb);
            }
        }
        catch (const IOError& e)
        {
            // after writing the request, the first read request may
            // detect, that the server has already closed the connection,
            // so check it here
            if (_readHeader && _reconnectOnError && _request != 0)
            {
                log_debug("reconnect on error");
                _socket.close();
                _reconnectOnError = false;
                reexecuteBegin(*_request);
                return;
            }

            throw;
        }
    }
    catch (const std::exception& e)
    {
        _errorPending = true;
        _client->replyFinished(*_client);

        if (_errorPending)
            throw;
    }
}
开发者ID:AndreasWelchlin,项目名称:cxxtools,代码行数:52,代码来源:clientimpl.cpp

示例3: onInput

void RpcClientImpl::onInput(StreamBuffer& sb)
{
    try
    {
        _exceptionPending = false;
        sb.endRead();

        if (sb.device()->eof())
            throw IOError("end of input");

        while (_stream.buffer().in_avail())
        {
            char ch = StreamBuffer::traits_type::to_char_type(_stream.buffer().sbumpc());
            if (_scanner.advance(ch))
            {
                _scanner.finish();
                IRemoteProcedure* proc = _proc;
                _proc = 0;
                proc->onFinished();
                return;
            }
        }

        if (!_stream)
        {
            close();
            throw std::runtime_error("reading result failed");
        }

        sb.beginRead();
    }
    catch (const std::exception&)
    {
        IRemoteProcedure* proc = _proc;
        cancel();

        if (!proc)
            throw;

        _exceptionPending = true;
        proc->onFinished();

        if (_exceptionPending)
            throw;
    }
}
开发者ID:jouven,项目名称:cxxtools,代码行数:46,代码来源:rpcclientimpl.cpp

示例4: onInput

void Socket::onInput(StreamBuffer& sb)
{
    log_debug("onInput");

    sb.endRead();

    if (sb.in_avail() == 0 || sb.device()->eof())
    {
        close();
        return;
    }

    if (_responder.onInput(_stream))
    {
        sb.beginWrite();
        onOutput(sb);
    }
    else
    {
        sb.beginRead();
    }
}
开发者ID:maekitalo,项目名称:cxxtools,代码行数:22,代码来源:socket.cpp

示例5: onInput

void Socket::onInput(StreamBuffer& sb)
{
    log_debug("onInput");

    sb.endRead();

    if (sb.in_avail() == 0 || sb.device()->eof())
    {
        close();
        return;
    }

    _timer.start(_server.readTimeout());
    if ( _responder == 0 )
    {
        _parser.advance(sb);

        if (_parser.fail())
        {
            _responder = _server.getDefaultResponder(_request);
            _responder->replyError(_reply.body(), _request, _reply,
                std::runtime_error("invalid http header"));
            _responder->release();
            _responder = 0;

            sendReply();

            onOutput(sb);
            return;
        }

        if (_parser.end())
        {
            log_info("request " << _request.method() << ' ' << _request.header().query()
                << " from client " << getPeerAddr());
            _responder = _server.getResponder(_request);
            try
            {
                _responder->beginRequest(_stream, _request);
            }
            catch (const std::exception& e)
            {
                _reply.setHeader("Connection", "close");
                _responder->replyError(_reply.body(), _request, _reply, e);
                _responder->release();
                _responder = 0;
                sendReply();

                onOutput(sb);
                return;
            }

            _contentLength = _request.header().contentLength();
            log_debug("content length of request is " << _contentLength);
            if (_contentLength == 0)
            {
                _timer.stop();
                doReply();
                return;
            }

        }
        else
        {
            sb.beginRead();
        }
    }

    if (_responder)
    {
        if (sb.in_avail() > 0)
        {
            try
            {
                std::size_t s = _responder->readBody(_stream);
                assert(s > 0);
                _contentLength -= s;
            }
            catch (const std::exception& e)
            {
                _reply.setHeader("Connection", "close");
                _responder->replyError(_reply.body(), _request, _reply, e);
                _responder->release();
                _responder = 0;
                sendReply();

                onOutput(sb);
                return;
            }
        }

        if (_contentLength <= 0)
        {
            _timer.stop();
            doReply();
        }
        else
        {
            sb.beginRead();
        }
//.........这里部分代码省略.........
开发者ID:913862627,项目名称:cxxtools,代码行数:101,代码来源:socket.cpp


注:本文中的StreamBuffer::device方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。