Indy > BroadCast to 172.30.58.255 fail

时间:2015-04-23 05:45:49

标签: c++builder

My environment:

C++ Builder XE4
Indy 10.5.8.3

I am trying to broadcast to network 172.30.58.X with subnet mask 255.255.255.0.

Using TIdUDPClient, I tried following resulting in fail (no response).

// case1 
IdUDPClient1->BroadcastEnabled = true;
IdUDPClient1->BroadCast(cmd, port, L"172.30.58.255");

Instead, the following works, but from unlimited network (also including those other than 172.30.58.XXX)

// case2
IdUDPClient1->BroadcastEnabled = true;
IdUDPClient1->BroadCast(cmd, port, L"255.255.255.255");

With the Indy, how can I broadcast only to 172.30.58.XXX?

1 个答案:

答案 0 :(得分:1)

在执行访问TIdUDPClient.Binding属性的任何内容(例如Broadcast()Connect() / ActiveSend/ReceiveBuffer()等)之前,请设置{{1连接到TIdUDPClient.BoundIP网络的本地IP的属性。