求助IdUDPServer控制使用方法啊!

麦子邪 2015-06-18 03:21:32
今天尝试使用IdUDPServer控件,进行UDP通信,结果发现,如果直接在控件的Bindings里直接配置IP和端口号的话,就完全没有问题,但是,如果手动配置的话,一运行就会提示地址或端口号占用的问题。

我想知道我这样操作,为什么会失败呀~~~,本地帮助文档里没有这个控件的帮助内容。

我在本地一个button单击事件里写了这样的操作:、

IdUDPServer1->Binding->SetBinding|(L"127.0.0.1", 4000u, 0x0);
IdUDPServer1->Binding->Bind();
IdUDPServer1->Active = true;

结果一运行就会出现绑定失败的问题,哎,好无语啊!求助啊!!
...全文
360 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
麦子邪 2015-06-19
  • 打赏
  • 举报
回复
引用 3 楼 缘中人的回复:
IdUDPServer1->DefaultPort = 8090;
IdUDPServer1->Active = true;
两句话就可以了
额,我实际想操作的是其它IP地址,因为当前电脑没有连接网线,于是先使用本地IP试试了。
缘中人 2015-06-19
  • 打赏
  • 举报
回复
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdTCPServer_OnExecute.html 是个只读属性 TIdUDPBase.Binding Property TIdUDPBase Class TIdUDPBase Members Collapse All Socket handle for the read or write transaction. Pascal property Binding: TIdSocketHandle; Description Binding is a read-only TIdSocketHandle property that represents the socket binding used to send and receive datagrams for the UDP component. Unlike TCP, UDP does not create a permanent connection to the remote computer. Binding is allocated when Active is set to True, or when methods that read or write to the socket handle are called. Binding is also updated when Broadcast iscalled, to ensure that socket options for the socket handle include the proper setting for the Id_SO_BROACAST flag.
缘中人 2015-06-19
  • 打赏
  • 举报
回复
Binding Socket handle for the read or write transaction.
缘中人 2015-06-19
  • 打赏
  • 举报
回复
IdUDPServer1->DefaultPort = 8090;
IdUDPServer1->Active = true;
两句话就可以了
麦子邪 2015-06-18
  • 打赏
  • 举报
回复
但是,不明白IdUDPServer1->Binding->SetBinding|(L"127.0.0.1", 4000u, 0x0);这个设置用来干什么使的?IdUDPServer1->Binding->Bind();这个操作又是干啥使的?
麦子邪 2015-06-18
  • 打赏
  • 举报
回复
刚才试了下,有新的发现,发现这样操作是可以的: TIdSocketHandle *sh=IdUDPServer1->Bindings->Add(); sh->IP ="127.0.01"; sh->Port=4000; IdUDPServer1->Active=true;

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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