I'm in the process of writing a small program which will connect to a FTP server running on an Android phone (which is connected via WiFi to the same network). I have no control over the Android code for the FTP server.
The problem is that the PC running my program and the phone have IP addresses allocated dynamically and both of these IP addresses change often.
I could assign fixed IP addresses at the router level, but I'd like something a little smarter and more consumer friendly. As a result, I think I need my program to scan all the IP addresses looking for the phone with the FTP server running.
Initial research suggests I should work out the PCs IP address and subnet mask and then use that to calculate the IP range to scan.
So for example, if the PC is 192.168.1.70
and the subnet mask is 255.255.255.0
then my program should scan from 192.168.1.1
to 192.168.1.254
to find this phone with the FTP server.
Given that I cannot change the FTP server code to do any kind of broadcasting, is this the right way to scan for the existence of a service? If not, how should I be doing this?
As a bonus point: is there an easy way to calculate what range I should be scanning in VB.net?