For my Android app, users need to connect to a server that will be hosted somewhere on the same LAN. There can be multiple servers hosted on the same LAN. To make it easy for the user, I was going to scan the current LAN that the Android device is connected to and then list all of the network devices that have the server running on it, rather than having the user input the IP to the computer manually.
I'm fairly new to networking, and after some searching I found out that I would have to use a multi-cast DNS search or UDP broadcast to detect the other devices. I also found a nice library called jmDNS, although I've found very few documentation and sample code on it. Could somebody point me in the right direction for what I'm trying to do to save me wasted time (mostly if I'm on the right track)? I'm assuming that I'll have to modify my server a bit to broadcast it's there? It works completely as intended if I input the IP manually into the configuration page on my app. Also, this only needs to discover Windows computers, not sure if that matters. Thanks in advance.
Well, jmDNS is a complete Java library that you could use for your setup. It can be used to braodcast your services which other clients can search for.
Bounjour service on windows is a bit tricky, although it's definitely possible. The easier way, I would say is to use jmDNS for broadcast and discovery for both your servers and clients.
You would run the jDMs or other service on your local area network as a background service or a dameon.
Related
I need some help in terms of choosing a design option for my problem.
I currently managed to implement a RaspberryPi acting as a Server and my local machine to act as the client. This client send JSON-Data to the Server which processes these. Everything is working as expected and I am using TCP-Sockets for the communication.
My problem:
The next step of my project will be, that I will use instead of a PC an Android-Device as client. What I want to achieve is, to send data to the server on the go. What I mean by that is, I do not want to restrict the server to be in a special network neither the client. What can be expected, is that server and client are next to each other, like in the range of a bluetooth connection. My question is, is there a relatively simple way to implement this communication? Is TCP a possible solution for this (even working in mobile networks?) or do I need to use Bluetooth, or is the way to go, to create some kind of network the client/server connects to and communicate here?
Sorry for propably stupid questions, but I am new to all this network stuff.
EDIT:
Since there were no respones, maybe I can do a more precise question. Is there a proper way to scan a network for a device name?
The only way I currently can imagine is to do a bruteforce like check on every IP-Address and resolve the names?
I first tried to let the Pi host an ad-hoc network, but it seems that non-rooted android smartphones do not have the possibility to access ad-hoc networks.
Therefore I made the Pi acting as an access point.
The communication now is very simple realized by a tcp server-client system.
I am developing currently an Android application that will communicate with other Android devices per Wifi. The Wifi will also provide the online connection. There is no server in this Wifi environment.
The idea was that the devices will discover each other with UDP multicast messages. But we noticed that UDP multicast often does not work on the devices. Sometimes it does, sometimes not.
To work around this issue we implemented a mechanism where the devices will store the local Ips online so that other devices will be able to retrieve them.
But this, of course, does only work if the Online State is available, which sometimes is not.
My question is, if there are other techniques with what the devices are able to connect per Wifi to the each other without knowing it´s Ip in the first place. Is there an easy way to forward the addresses per Bluetooth for example? Or could Wifi Direct be an option?
Every idea is welcome. Thanks for all of your help.
A zero configuration networking solution might work for you. There is a Nuget package called zeroconf that should work with Xamarin:
https://www.nuget.org/packages/Zeroconf/
Source code:
https://github.com/onovotny/Zeroconf
I am working on a Phonegap application and I want a means by which two people with this app installed can share some information offline, but on the same network like a wifi or tethered hotspot.
I have tried to search the web for possible libraries or ways of doing it, but all I see are libraries that pass the data through their servers before sending it to the peer, meaning they must be online.
So please can someone point me to the right direction on how to do this or to the valid resources available.
Thanks
I've used sockets-for-cordova for communicating between a cordova app and an Arduino. However, seeing as it's TCP it wouldn't support broadcasts - you'll need a UDP socket for that.
There is also cordova-plugin-chrome-apps-sockets-udp which does appear to support broadcasts. I've no experience with it though.
I want to send notification from one android device (android tv without bluetooth, telephony) to another android device (phone/tablet). Both are on same wifi network. Through the notification, I want to launch an app or open a page in phone/tablet browser.
I went through GCM messaging and also saw some options where we can have a kind of http server on the phone running but could not understand implementation.
Can someone help with idea and if possible, some piece of code as well.
As I need it for demo, so even any hack solution is fine for me :-)
Thanks for any help or reading.
Your best bet as a hacky solution is to do simple Socket connection between two devices. Since they are on same Wifi, it will be simpler and won't have any firewall restrictions.
Avoid GCM, it requires setting up a GCM Server and then complex registration. It also makes your solution dependent upon Internet connectivity & Google ofcourse.
See an example here:
http://android-er.blogspot.in/2014/02/android-sercerclient-example-client.html
Basically one device such as TV can be a socket listener. The phone/tablet can connect to that socket and then you can initiate a notification on either device based on your requirements and data exchange.
Is there any way to send request from a server to an Android phone? Actually, I want to control an application (enable or disable some features of the application) in an Android phone by a server. Can I use the IP Address of the Android device?. Can anyone guide me.
Thank you!.
Much simpler way is for phone to contact server and ask should features be enabled. You could also use something like this http://code.google.com/android/c2dm/ but I'm not sure if this is an overkill for your use case.
If the above option is not suited for your case then you can create a simple service
for your application and then attach to application.
The service can be a thread which sends requests to the server with some time intervals that you find suitable and can check if there is anything to check and to do for the application.
And also can run in background.
All push services are usually implemented as well concealed polling. Phones on 3G networks usually sit behind NAT proxies and are not visible to outside world. The same holds for most wlan networks - so either use C2DM, or write your own service polling config information from some server provided by you