Unable to Ping Smartphones Using Java - java

I'm currently making a Java application that detects when smartphones connect to our home network. I'm able to get the IP addresses of all of the "remembered" devices on the network, ping the devices currently active on the network like desktops and laptops, but when I try to ping smartphones (either from command line or from the Java application using the InetAddress's isReachable() method) the requests time out.
Is this a problem with a security setting on our router? Do the phones (iPhones) themselves have security that prevents this? Is there any other Java code I can use to detect when these smartphones are or aren't active on the network? I haven't been able to find a particularly helpful answer so far in previous questions.
Thank you for reviewing my question!

It might be a good idea to inspect your network with Wireshark, or with an other similar software to see what is going on behind the scenses on your neteork. If you use linux, you may want to try the unix command arp-scan, which does network discovery for you.

Related

Cross-platform server application to communicate with Android/iOS on WiFi

I am working on an application where I need to establish a server on a Windows/Linux/Mac machine which will need to communicate to an Android/iOS device over an existing WiFi network.
I am just in the research phase for now, and though I can find answers for communicating between PC-Android, PC-iOS, Mac-iOS etcetera, I cannot find an answer using which I can do all of it.
The mobile application will be different for both the platforms, of-course, but the server application should ideally be the same, and should be cross-platform.
I should also mention that the server and the clients(mobile-apps) will maintain a 1:n relation, meaning that several Android/iOS devices will be communicating with the server at once.
I need advice on which language/library shall I use for the server which would let the it communicate to both the mobile platforms.
Advice on the libraries I should use for the mobile platforms will also be helpful, though it's not important until I complete the server.
I am just looking for links to helpful resources, though I will be very grateful if you share some code.
I shall also mention, I know Python/Java/C++ which I can use for the server, but you are open to suggest another language which may make the work easier.
EDIT: What I forgot to mention is that, this will be a local server, that is, it needs to communicate with these devices on a LAN (devices on the same wifi network).
If you Know Java for the server side you cab create an application that hosts a RestFull API running on a tomcat server that you call with a local address (such as http://ip_adress:port/appname)
Tomcat can run on Windows, Linux or Mac.
If you need more informations just ask

Uniquely connect an android application to a java applet on pc

I want to connect my android application to an applet which is running on my pc on Google chrome on Wi-fi.. where my phone works as a wi-fi hotspot and pc as the connected device. I want the connection to work uniquely as I want commands to be passed from my application to the specific applet, on the execution of which my applet does specific tasks. Please tell me the APIs which I can look in both Java and Android or the technology I have to use to make it work..
You need to use any program, such as wamp server, to make your computer to be a localserver. It will install PHP 5, MySQL and Apache. In other hand, you will also need a little bit of knowledge in Php language to create you own web services.
Another thing you need to be aware is that to handle you connection between server and device (and by this I mean which IP you are going to use) you will have a little headache; but first things first..break your problem in little parts thus will be easier to solve them.
I recommend this tutorial.
I think the simple way to connect these two softwares is using UDP.
It is fast, it is easy to program but it is generally unreliable according to TCP. But it is already local network. I dont think that is a case you need to take care in your local wifi network.
So take a look at this tutorial http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html
There are other ways like https://www.alljoyn.org/. It has more functinality but more complicated.
You must install Server on your PC(Apache httpd or apache tomcat or other based on your interest). A server listens to request from clients. When your mobile is connected to your pc(doesn't matter wire or wireless), you can make a request to an url(say, localhost:8080/welcome) from your app.
Create an applet and connect it with your web application(in the server) using java.net.URL and java.net.URLConnection.
On performing some operation on the client, call the url of the server application and forward the response to the applet.

Connecting to lan network

I am writing a platform game, and i thought it would be cool to add a multi-player mode for people who are playing on the same network. My question is how would i query through all the available computers open on a certain port for connecting to play multi-player, and then how would i establish a connection with them. I thought i could just create a socket and just try to connect on every port, but how would i do that if i dont know the other computer ip address. On google i saw this question get asked several times, however none of the answers actually seemed helpful.
You will propably want to broadcast a message (broadcasts are received by all devices on the network). Then you would have the other machines listening fir such incoming broadcasts.
Basically in a broadcast you would advertise that a computer is running the program, and is willing to establish a direct connection. Then one of the computers would connect straight to the other, and you would work on from there.
EDIT: Someones similarily done aproach in java (blog post)

Broadcast a message to all available machines on WiFi

my apologies if this is a trivial question.
I've recently begun doing some android programming and I'm writing a simple app that allows you to use your android device as a controller for your windows PC. Specifically it allows the user to do things like turn off the machine, make it sleep, reboot it etc etc. I'm currently using a python library called CherryPy as a server on the windows machine to execute the actual win32api calls to perform the desired function. What i'm not sure about is how to discover (dynamically) which machine on the network is actually hosting the server. Everything is working fine if I hardcode my machines public IP into the android app, but obviously that is far less than ideal. I've considered having the user manually enter their machines public IP in the app, but if there's a way to, say, broadcast a quick message to all machines on the WiFi and check for a pre-canned response that my Python server would send out, that'd be wonderful. Is that possible?
Thanks in advance guys.
Try sending a UDP packet to the special broadcast address 255.255.255.255. Every device in the network should receive a copy of that packet (barring firewalls), and you can arrange to have the server reply to the packet with its identity.
Write your app using the alljoyn framework. AllJoyn will handle these details for you.

Java network communication problem

I have a problem that I think might be a java related one.
I have a java application I need to emulate multiple hosts.
The server/client work fine between "normal" computers.
When I use the emulator, I get connection refused when client tries to connect to a server in the emulator, same thing if I try telnet.
If I turn it around, the client cannot connect to the external server, but if I telnet from the external server, I get a connection.
This makes me think it is a java related problem.
Anybody gone through this problem before? This is for research purposes, so turning off java security only for this situation is no problem.
Thanks!
When you say emulator, I think you are talking about a virtual machine. Connecting from the real world into a virtual machine is not something that works automatically. The virtual machine can initiate connections out because the virtualization software handles that. Going the other way - what machine name do you use. How you configure your physical machine to routce packets to the ip address of your virtual machine (which your virtualization software made up). You may need a proxy on your physical machine to route the packets into the virtual one.

Categories

Resources