Reputation: 16619
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.
Upvotes: 2
Views: 1050
Reputation: 383
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)
Upvotes: 1