bool download_source::is_eof() { dgd_scopef(trace_download); if( m_eof ) return true; if( m_tail == m_head ) { int msgs_remaining = 0; do { CURLMsg *msg = curl_multi_info_read( m_mcurl, &msgs_remaining); if( msg != NULL && msg->msg == CURLMSG_DONE) { if( msg->data.result != CURLE_OK ) { std::ostringstream ostr; ostr << "Error while reading from URL '" << m_url << "'. " << "Error code: " << msg->data.result << ". Description: " << curl_easy_strerror(msg->data.result); m_error_string = ostr.str(); dgd_echo(m_error_string); if( m_error_callback != NULL ) { m_error_callback(m_error_string); } } m_eof = true; dgd_echo(m_eof); return true; } } while( msgs_remaining > 0 ); } return false; }
void tcp_pkt_sender_t::handle_write(const boost::system::error_code& error, std::size_t bytes_transferred, std::string* buffer_ptr) { if (!error) { all::core::BOOST_SLEEP(1); } else { printf("Error in tcp_pkt_sender_t::handle_write:\n %s", error.message().c_str()); if (m_error_callback) m_error_callback(error); } delete buffer_ptr; }
void stream_pkt_receiver_t::handle_read_data(const boost::system::error_code& error, std::size_t bytes_transferred) { if (!error) { //printf("read %i bytes\n", bytes_transferred); m_packet_ptr.reset(new stream_packet_t()); //build packet if (!m_packet_ptr->build_packet_from_string(m_in_data_buffer, bytes_transferred)) { printf("Error building packet from socket\n"); //start waiting for next packet if (m_listen_f) //async->returns immediatly read_packet(); if (m_error_callback) m_error_callback(boost::asio::error::no_data); } //invoke read callback else { //start waiting for next packet if (m_listen_f) //async->returns immediatly read_packet(); if (m_read_callback) m_read_callback(m_packet_ptr); } } else { if (m_error_callback) m_error_callback(error); } }