PDA

View Full Version : Use QUdpSocket as a QIODevice (read, readline, write)



salcin
9th April 2014, 21:17
Hi,

I would like to use QUdpSocket as a QIODevice (read(), readLine(), write()). In my application I want to be able to send data over UDP or RS-232 using QSerialPort (which also is a QIODevice).
QUdpSocket's documentation state that to be able to use the udp socket as a QIODevice, connectToHost() must be called. After I called connectToHost() I can write data, but I can't read data. Calling bind doesn't help.

I have provided a short example which displays the problem. Write some text in the line edit, press send and it shall be sent to the right textbrowser which will send a new UDP datagram that should show up in the left textbrowser. Broadcast addresses are used.

Edit: I'm using Qt 5.2.1 on Windows 7
Thanks!