procedure TfrmMain.mnuMulticastClick(Sender: TObject);
var
//basic communication as captured by Wireshark
{00 00 - Transaction ID
00 00 - Standard query
00 01 - Question count
00 00 - Answer RRs count
00 00 - Authority RRs count
00 00 - Additional RRs count
xx xx - query string/question string
00 0c - Type PTR
00 01 - Class IN}
query: TIdBytes = ($00, $00, $00, $00, $00, $01, $00, $00, $00, $00,
$00, $00, $09, $5f, $73, $65, $72, $76, $69, $63, $65, $73, $07,
$5f, $64, $6e, $73, $2d, $73, $64, $04, $5f, $75, $64, $70, $05,
$6c, $6f, $63, $61, $6c, $00, $00, $0c, $00, $01);
begin
//set CastServer
IdIPMCastServer.MulticastGroup := Id_IPMC_mDNS;
IdIPMCastServer.BoundIP := String_IP_Address; //Here goes the IP address of your network adapter
IdIPMCastServer.BoundPort := 49152; //my favorite port. Pick one that is not used by other apps in your network. Other devices will use this port to answer your query
IdIPMCastServer.Port := 5353; //this is standard
//set UDPServer
IdUDPServer.Bindings.Add;
IdUDPServer.Bindings[0].IP := String_IP_Address; //Here goes the IP address of your network adapter
IdUDPServer.Bindings[0].Port := 49152;
//send Query
IdIPMCastServer.Active := True;
IdIPMCastServer.Send(query);
//deactivate CastServer, activate UDPServer and deactivation timer for UDPServer
IdIPMCastServer.Active := False;
tmUDPdeactivate.Interval := IdIPMCastServer.TimeToLive * 1000;
tmUDPdeactivate.Enabled := True; //I use a timer to deactivate the IdUDPServer after 5 seconds of waiting for messages. You need this if you want to send another query with IdIPMCastServer because of shared port
IdUDPServer.Active := True;
end;