hello
I'm working on this thing.
I'm not experienced with UDP anyway i have wrote some code that seems to work.
I do the following:
1) Setup the udpclient with the following settings;
UDPMULTICAST=true
UDPMULTICASTMAXHOPS=255
MULTITHREADED=false;
SERVERADDR=192.168.2.255
SERVERPORT=81;
2) Open the udpclient component
3) Write a query string ('QUERY SERVER')
4) In the server ondatareceived i check if the text received is QUERY SERVER
5) If the data received is correct i write back the IP of the pc (i tought that the property LocalAddr returned it but i see it's empty, so i have used another function)
6) In the ondatareceived event of the udpclient i add the ip address received to a global stringlist
I use a code similar to the following to begin the query in the client side.
I see it works but i'k not sure if i'm doing it in the right way. Sincerly i expected it didn't work because
when i do the first write to query servers (Write('QUERY_SERVER')
the execution should immediately continue and the stringlist should be then empty. I'm surprised to see that the stringlist is populated with the up address of the servers. Does it mean that the WRITE method wait for all the servers have replyed ?
Fserver_list:=Tstringlist.Create;
try
Write('QUERY SERVER');
// Now i have the stringlist populated with the IP address of the RTC servers found in the LAN
for idx := 0 to Fserver_list.count-1 do
begin
showmessage(Fserver_list[idx]);
end;
finally
Fserver_list.Free;
end;