0

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?

Richard
  • 1,471
  • 7
  • 23
  • 47
  • Is the device *name* unknown to the client ? Also: what if another FTP server happens to be active on the network ? – Alex Dec 16 '14 at 15:35
  • I've tried running `nbtstat -A` with the IP address of the phone and nothing is returned, so am I right in assuming that the device name is unknown? It doesn't matter if there are other FTP servers as the program will attempt to connect (using supplied credentials) and continue scanning if they don't work. – Richard Dec 16 '14 at 15:46

1 Answers1

0

Since you know nothing about the server (neither the name, nor the address), hunting it down through a range scan seems the only way.

About the range, you can find the solution elsewhere on SO, for example this question seems good.

Community
  • 1
  • 1
Alex
  • 23,004
  • 4
  • 39
  • 73