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:

Qt Code:
  1. udp.connectToHost(hostName, hostPort); // connected
  2. udp.bind(hostName, hostPort); // trigger Q_CHECK_STATE, require unconnected states
To copy to clipboard, switch view to plain text mode 

or
Qt Code:
  1. udp.bind(hostName, hostPort); // bound
  2. udp.connectToHost(hostName, hostPort); // cannot connect to host, leave in error states
To copy to clipboard, switch view to plain text mode