QUdpSocket无法bind

haltwang 2012-09-27 09:09:27
在网上下载了个用Qt写的类似QQ的软件,调了IP,建了数据库终于能注册登录了,发现不能获取好友列表。
一点点看发现:
bool x = udpsocket->bind(QHostAddress::Any, udpport); //udpport=45454
qDebug()<<"bind:"<<x;
输出的结果为false,也就是说不能bind,求大神指点为什么会这样?
...全文
885 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
花莫弦 2014-06-19
  • 打赏
  • 举报
回复
怎么解决的呀
donwmufromdying 2012-10-09
  • 打赏
  • 举报
回复
问题解决了吗?呵呵
haltwang 2012-10-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

问题解决了吗?呵呵
[/Quote]

差不多吧。
donwmufromdying 2012-09-28
  • 打赏
  • 举报
回复
同一台机器有影响!!!,如果你不是QUdpSocket::DefaultForPlatform(the default option for the current platform. On Unix and Mac OS X, this is equivalent to (DontShareAddress + ReuseAddressHint), and on Windows, its equivalent to ShareAddress.)
则一个端口只能被bind给一个udpsocket.
haltwang 2012-09-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

同一台机器有影响!!!,如果你不是QUdpSocket::DefaultForPlatform(the default option for the current platform. On Unix and Mac OS X, this is equivalent to (DontShareAddress + ReuseAddressHint), and on Windows, its equ……
[/Quote]
那是不是吧参数设置为:ShareAddress就可以了,我昨天试验了没用。
是不是要吧所有的Bind都换成ShareAddress呢,这个我到没试过
haltwang 2012-09-27
  • 打赏
  • 举报
回复
对,我服务器,还有客户端都是自己的电脑会不会有影响。

16,817

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧