I am trying to create an UDP communication between two hosts using boost library, but instead of sending/receiving a string i want to send a std::vector<std::complex<double>
structure.
To be more specific, i have a greater function that returns me a buffer of std::vector<std::complex<double>
type. By using .front() i can see the values from the buffer. The catch is that i want to use buffer.front() as an argument to a sender function, namely "auto sent = socket.send_to(boost::asio::buffer(buffer.front()), remote_endpoint, 0, err);"
I attached a part of the code of interest if it helps:
void Sender(std::vector<std::complex<double>> in) {
boost::asio::io_service io_service;
udp::socket socket(io_service);
udp::endpoint remote_endpoint = udp::endpoint(address::from_string(IPADDRESS), UDP_PORT);
socket.open(udp::v4());
//std::cout<<"The message is:"<< in<<std::endl;
boost::system::error_code err;
auto sent = socket.send_to(boost::asio::buffer(in), remote_endpoint, 0, err);
socket.close();
std::cout << "Sent Payload --- " << sent << "\n";
}
int main()
{.....
.....
.....
for (int i = 0; i < 20; ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
Sender(buff.front());
}
My problem is in the Sender argument what should i have instead ofstd::vector<std::complex<double>
because is now working, i get an error of conversion, and the next question is if it is possbile of doing this, i mean sending this type of data.
I also attached the error that return me if i try to compile:
error: could not convert ‘input.std::vector<std::complex<double> >::front()’ from ‘__gnu_cxx::__alloc_traits<std::allocator<std::complex<double> > >::value_type {aka std::complex<double>}’ to ‘std::vector<std::complex<double> >’
Sender(input.front());
Thank you!
Aucun commentaire:
Enregistrer un commentaire