QtCreator and boost::asio::ip::udp::socket vs QUdpSocket
I am writting a program with QtCreator which is intended to receive UDP data
from the source sending about 20 MBps (on the local machine for the time being).
At the begininig of my project I used QUdpSocket object but I realized
that it was to slow and can NOT keep up to receive so many data.
Some online forums I was confirmed that it is true - QUdpSocket is slow
and I was advised to use boost::asio::ip::udp::socket. I connected it to QtCreator
and wrote code on the tutorial
Hovever I have some problems.
The structure of Qt project is not adequate to the code from the tutorial.
@int main(int argc, char *argv)
QApplication a(argc, argv);
port1 = new UdpReceiver(io_serv);
io_serv.run(); // <- it is very important
std::cerr << e.what() << "\n";
boost::array<char, 1> rec_buffer;
UdpReceiver(boost::asio::io_service & io_serv);
void handle_receive(const boost::system::error_code& error,
@UdpReceiver::UdpReceiver(boost::asio::io_service & io_serv):
sockPort(io_serv, udp::endpoint(udp::v4(), 7755))
void UdpReceiver::handle_receive(const boost::system::error_code& error,
if (!error || error == boost::asio::error::message_size)
std::string err = error.message();
std::string ss = error.message();
std::cerr << ss << " " << error.value() << "\n";
Application enter to function handle_receive properly when receiving data
but the first condition is always FALSE.
The second condition (else) is performed and prints
error 234 - More data is available.
What does it mean? Where did I make an error?
Could someone help me?
Is it true that QUdpSocket is such slow?
Thanks for your help in advance.
Your question seems to be about boost not Qt. Maybe you should ask your question on a boost forum/mailing list.
ckakman, you are right but I asked among others very important question concerning Qt. The question was: "Is it true that QUdpSocket is such slow?".
Could anyone answer me?
[quote author="Milosz" date="1421653198"]Is it true that QUdpSocket is such slow?[/quote]Try it :) Write two different programs, where one uses QUdpSocket and the other uses boost::asio::ip::udp::socket. See if you notice any difference.