Scan for Kodi devices

I am programming in VB6 and trying to figure out the best way to scan for active kodi devices.
I have managed to get TCP working with json ie send and receive. Figured out how to switch
on and off.

I would really like to know how to scan a network and find kodi devices.
I have managed to do it with pinging and then testing for specific responses from kodi.
If i get a response then add to list if not move onto next ip address.

Is there any inbuilt command to get the host name that can be issued.

I have seen that a TCP UDP can be broadcast and then all kodi devices respond.
What command needs to be sent.Confused

i really need some help.

thanks