我想做個broadcast和讀取回應的App,使用TIdUDPClient這個元件
但卻連broadcast都送不出去(Wireshark去看網路封包)
請問,問題出在哪裡呢?可否指導一下網路的這些元件該怎樣使用呢?
感謝!
//IdUDPClient1->Host = BROADCAST_IP;
//IdUDPClient1->Port = BROADCAST_PORT;
for(int i=0;i<20;i++) {
IdUDPClient1->Active = true;
IdUDPClient1->BroadcastEnabled = true;
IdUDPClient1->Broadcast(HeadData, BROADCAST_PORT);
DelayTime(1000, true);
RecvData = IdUDPClient1->ReceiveString(RECEIVE_TIMEOUT);
if(RecvData.Length()>0) {
redtIPList->Lines->Append(RecvData);
break;
} else {
redtMsg->Lines->Append(AnsiString("Re-try count is ")+ (i+1));
}
IdUDPClient1->BroadcastEnabled = false;
IdUDPClient1->Active = false;
}