Exemplo n.º 1
0
Connection::Connection(std::shared_ptr<boost::asio::ip::tcp::socket> client_socket, WebApplication *application_pointer) : application_pointer_(application_pointer), client_socket_(client_socket), timeout_timer_(client_socket->get_io_service()), current_request_(new HTTPRequest)
{
    resetTimeoutTimer();
    startAsyncRead();

    std::lock_guard<std::mutex> lock_guard(connections_count_mutex_);
    connections_count_++;
}
Exemplo n.º 2
0
void QLocalSocketPrivate::_q_notified()
{
    Q_Q(QLocalSocket);
    if (!completeAsyncRead()) {
        pipeClosed = true;
        emit q->readChannelFinished();
        return;
    }
    startAsyncRead();
    pendingReadyRead = false;
    emit q->readyRead();
}
Exemplo n.º 3
0
void QLocalSocketPrivate::_q_notified()
{
    Q_Q(QLocalSocket);
    if (!completeAsyncRead()) {
        pipeClosed = true;
        emit q->readChannelFinished();
        if (actualReadBufferSize == 0)
            QTimer::singleShot(0, q, SLOT(_q_pipeClosed()));
        return;
    }
    startAsyncRead();
    pendingReadyRead = false;
    emit q->readyRead();
}
Exemplo n.º 4
0
void Connection::startAsyncRead()
{

    client_socket_->async_read_some(boost::asio::buffer(buff_), [this](const boost::system::error_code& e, std::size_t size)->void
    {
        if (e)
        {
            BOOST_LOG_TRIVIAL(error) << e.message();
        }
        else
        {
            onDataRead(size);
            if (client_socket_->is_open())
                startAsyncRead();
        }
    });
}
Exemplo n.º 5
0
void QSerialPortPrivate::_q_completeAsyncCommunication()
{
    Q_Q(QSerialPort);

    DWORD numberOfBytesTransferred = 0;

    if (!::GetOverlappedResult(handle, &communicationOverlapped, &numberOfBytesTransferred, FALSE))
        q->setError(decodeSystemError());

    bool error = false;

    // Check for unexpected event. This event triggered when pulled previously
    // opened device from the system, when opened as for not to read and not to
    // write options and so forth.
    if (triggeredEventMask == 0)
        error = true;

    // Workaround for standard CDC ACM serial ports, for which triggered an
    // unexpected event EV_TXEMPTY at data transmission.
    if ((originalEventMask & triggeredEventMask) == 0) {
        if ((triggeredEventMask & EV_TXEMPTY) == 0)
            error = true;
    }

    // Start processing a caught error.
    if (error || (EV_ERR & triggeredEventMask))
        processIoErrors(error);

    if (triggeredEventMask & (EV_CTS | EV_DSR | EV_RLSD | EV_RING) )
    {
        QSerialPort::PinoutSignals signals_mask = 0;
        if (triggeredEventMask & EV_CTS)  signals_mask |= QSerialPort::ClearToSendSignal;
        if (triggeredEventMask & EV_DSR)  signals_mask |= QSerialPort::DataSetReadySignal;
        //No definition in PinoutSignals if (triggeredEventMask & EV_RLSD) signals_mask |= QSerialPort::ReceivedDataSignal;
        if (triggeredEventMask & EV_RING) signals_mask |= QSerialPort::RingIndicatorSignal;
        emit q->pinoutSignalsChanged(signals_mask);

    }

    if (!error && (triggeredEventMask & EV_RXCHAR) )
        startAsyncRead();
    else
        startAsyncCommunication();

}
Exemplo n.º 6
0
void QSerialPortPrivate::_q_completeAsyncRead()
{
    Q_Q(QSerialPort);

    DWORD numberOfBytesTransferred = 0;
    if (!::GetOverlappedResult(handle, &readCompletionOverlapped, &numberOfBytesTransferred, FALSE))
        q->setError(decodeSystemError());

    if (numberOfBytesTransferred > 0) {

        readBuffer.append(readChunkBuffer.left(numberOfBytesTransferred));

        if (!emulateErrorPolicy())
            emitReadyRead();
    }

    // start async read for possible remainder into driver queue
    if ((numberOfBytesTransferred > 0) && (policy == QSerialPort::IgnorePolicy))
        startAsyncRead();
    else // driver queue is emplty, so startup wait comm event
        startAsyncCommunication();
}