Когда я вызываю метод start_receive () в приведенном ниже коде без вызова _outSocket.send (), метод получает данные из сокета без проблем, но когда я пытаюсь отправить данные из другого сокета, исключение повышенияброшенЯ не уверен, что является причиной проблемы, поэтому любая помощь будет отличной.
#include "dataproxy.h"
#include <boost/bind.hpp>
#include <cstdlib>
using namespace boost::asio;
DataProxy::DataProxy(boost::asio::io_service& ioserv)
: _inSocket(ioserv, ip::udp::endpoint(ip::udp::v4(), 5004))
,_outSocket(ioserv, ip::udp::endpoint(ip::udp::v4(), 5005))
{
}
DataProxy::~DataProxy()
{
}
void DataProxy::start(){
QThread::start();
}
void DataProxy::run()
{
while(true)
{
start_receive();
}
}
void DataProxy::start_receive()
{
/*_inSocket.async_receive_from(
boost::asio::buffer(_inBuffer), _videoEndpoint,
boost::bind(&DataProxy::handleIncomingData, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
*/
size_t reply_length = _inSocket.receive_from(
boost::asio::buffer(_inBuffer), _dataSourceEndpoint);
std::cout << "Received " << reply_length << " bytes" << std::endl;
//This is the line that causes the exception
size_t send_length = _outSocket.send(boost::asio::buffer(_inBuffer));
}