PDA

View Full Version : use QUdpSocket as a QIODevice



feverzsj
19th December 2012, 04:50
0 down vote favorite


according to qt4.8 doc:


If you want to use the standard QIODevice functions read(), readLine(), write(), etc., you must first connect the socket directly to a peer by calling connectToHost().

but:


udp.connectToHost(hostName, hostPort); // connected
udp.bind(hostName, hostPort); // trigger Q_CHECK_STATE, require unconnected states

or


udp.bind(hostName, hostPort); // bound
udp.connectToHost(hostName, hostPort); // cannot connect to host, leave in error states