2

I am trying to find and connect winform app with android tablets on LAN or WLAN.

I have implemented a tcp server on android, it is listening on port, and waiting requests.

I then tried to implement Winform app that should try to scan network to find this tablet by sending request to this tablet, and checking the response.

I stuck on the second part, how to check the network and send request to this port efficiently? I need to find out the ip of the tablets in order to connect them.

I found this code: NetworkBrowser

but it checks for PCs on the network, it does not show Android tablets.

The first solution that came on my mind is to implement webservice, that will reciever from android and the PC will request periodically and get the IPs of the tablets. still not that efficient solution.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
MBH
  • 16,271
  • 19
  • 99
  • 149
  • Did you try this: http://stackoverflow.com/q/13198669/1207195? It looks promising. BTW you can _manually_ enumerate IP space (in parallel!) trying to connect to your Android TCP server. You may even set a short timeout and when it fails, well...that's not an android device with your app running. For small networks it won't take too long time (I guess ~30/40 seconds). – Adriano Repetti Dec 21 '15 at 08:13

1 Answers1

1

One possibility might be indeed a webservice. You can then let the android devices subscribe and unsubscribe to get an idea who is connected. It is usually easier that the clients seek the server than the other way around. You might set a threshold of e.g. 5 minutes if in this period the devices doesn't renew its subscription it then is marked as irresponsive and you can try to reach it again or forget it was subscribed server side. Here you might find examples how to consume a WCF webservice:

Networkwise i would recomend checking if this is not a problem posed by your router. Sometimes if you have a default setup some ports might be blocked and need unblocking in the router configuration. For this i recomend a tool lioke nmap:

You only have to know the devices ip to scan the open ports. In my case i found it under Settings > Wifi > Advanced > At the bottom you can see your Wifis MAC and IP (Android 6.0.1 , Nexus 5)

Community
  • 1
  • 1
knechtrootrecht
  • 383
  • 2
  • 11
  • The same project may be used in seperated locations, so the subscribe process will be serious overhead, login PCs' users with username and password, subscription tablets and security stuff will come up. I am trying to run away from this solution – MBH Dec 21 '15 at 08:26
  • 1
    Technically you are right. But WCF offers mechanisms for user and/or device authentification built in.(https://msdn.microsoft.com/en-us/library/ff405740.aspx) You do not want to roll this yourself. Another adnvatage of WCF is that the webservices can be used by different platforms as well. Maybe you need to Port it to a standalon version or iOS later, then you already have your bakcend. In my experience the authentification/registration to a webservice is an negligible overhead (Tried myself in a system of 500+ Concurrent Clients connecting to a single offsite server) – knechtrootrecht Dec 21 '15 at 08:33
  • THANK YOU. Since i have no good knowledge about web services, i was trying to stay away of it. But it is better solution for even tracking the project in later stages. Still couldnt find good tutorials to make it easy to start with the Login process, It would be great if you add more resources about log in and webservice. (Does web service have a session like a normal website as i have seen in one of your posted tutorials?) – MBH Dec 22 '15 at 10:24