QUdpSocket的问题

来源:互联网 发布:三星手机数据恢复 编辑:程序博客网 时间:2024/06/05 11:23

使用Qt4.6的QUdpSocket类,遇到一个极其坑爹的问题。

在Qt sdk文档中,对QUdpSocket的使用有如下描述:

The most common way to use this class is to bind to an address and port using bind(), then call writeDatagram() and readDatagram() to transfer data. 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().

于是我选择了第二种方式,使用 connectToHost()连接了通信的双方。然而,悲剧发生了,无论如何也不能把数据发送到对方。各种发送函数都试了。折腾了一整天后把目光盯到 connectToHost()上,删除,测试,一切按预想的发生!我已经出离愤怒了!

在此请过路的神仙和妖精们帮忙解释一下,是我用得不对还是Qt的sdk文档坑爹?
原创粉丝点击