Finding exact device in the LAN Java / Android - java

I'm developing a Java application which should listen on specific port on computer using Sockets.
The another app, which will run on Android device connected to the same WiFi, should find this computer with my Java program.
How can I find the computer in the network?
I've tried it in the small LAN (where are all devices connected to 192.168.*.*) using InetAddress.getByName(ipAddress).isReachable(); but in the bigger network (like eduroam or my school WiFi) I'm not able to scan whole network.
Is there another option how to connect two devices to each other apart from using Sockets and scanning whole network?

I'm not sure I understand your entire system requirements, but I'm thinking you could create a very small database at a hosting site (such as this) and have your PC periodically upload its private IP address to that database.
Then, when you need to connect to the PC on your android device, you query the database and determine the PC's current address, then connect to the device.

Related

Get Devices connected to same wifi network in android programmatically?

I am developing an app in which the first thing i need is how to get devices that are connected to my wifi network or same wifi network .ie ip adress,device name etc.
I don't have any idea how to do that have searched alot but there are no examples available.
I have done one thing that i will ping 255 ips and whichever will respond will be the connected ips but the problem here is that there are virtual ips already assigned to some websites so i need to detect only the real device ip addresses.
I want to do the same thing as done in the app WifiTalkie
Follow Any one of the following:
Way1:
If you mean you want to see all the devices connected to your current WiFi connection (and you are not trying to do Ad Hoc networking), then you are essentially wanting to run a network scanner.
There are a bunch of these around. This one has the source available on github
http://rorist.github.com/android-network-discovery/
Way2:
Refer How to detect all the Devices connected in a WiFi network from Android App

Wifi Game Detect Servers in Local Area Network

I created an Android/Desktop game which supports multiplayer on a local area network. I am using DatagramPackets and right now I have hard coded 2 local IP addresses for testing purposes.
How do I make it so when one device is hosting a game anyone else running the game can detect that hosted game on the LAN. Basically I need to get the Local IP Address of the person who is hosting my game from another device connected to the same router searching for a game on the network.
This is how I am currently detecting the other devices on the network by hard coding the address.
outgoingPacket.setAddress(InetAddress.getByName("192.168.1.20"));
I imagine I should be using a broadcast of some sort.
I suspect that you're looking for a more generic broadcast capability that's described here.
Multicast is a whole other kettle of fish!
I think that the best way to do this is to use 1 specific port for the games, and see if someone is online on that port in the network.

Connecting to Java Server via external IP

I have developed an application to transmit coordinates of one device to another and the distance between each is calculated. I wrote a java server and had been connecting both devices locally. However, now I want to test this over greater distances, in order to do so I need to connect one device to the external ip and use 3g in order to carry the device to over 500m.
I thought it might just have been a case of finding my external ip and putting that in where I had my local ip, however, there is no connection..I am still connecting the other device locally which is fine as there is no 3g on it anyway.
Does anyone have any ideas or suggestions as to what I need to do in this regard?
Thanks in advance,
Gary

2 Way Communication with Android Phone and PC via Internet

I am trying to control a Remote Control Car with an Andriod Phone from my PC (over 3g internet)
I'm planning on using a ioio (Which is just a board that I can plug into a andriod phone via USB)
The part I am working on now is the communication from my PC to my Andriod App. I've never made Andriod apps before and I'm a amateur C# developer.
At the moment I am planning on communicating via UDP as I can create a UDP server/client in Java easy enough. (http://systembash.com/content/a-simple-java-udp-server-and-udp-client/)
However I think this may require a public IP address? Which I will not have either on my client or server.
So for simplicty sake, How would you commucicate over the internet between 2 JAVA applications. If you need to stream video from a camera and simple commands.
You don't necessarily need a public IP, you just need some sort of IP with which one device can send packets to the other. For example, you could connect the phone to your home wifi network, and use the private IPs (typically 192.168.1.x) of the two devices.
If you need the phone to be on 3G, and your PC is behind a NAT router (which is typical), then you'll need to forward a port to your PC — this is a configuration setting on the router — and then have the phone connect to that port on your router's public IP.

Java application on Windows system running as USB peripheral

Is there a way to have a USB device act as a Host and an application on a Windows based system to act as the Peripheral? We have a USB device that is the host and we need it to connect to our application running on a Windows based system. The device is using USB 2.0 On-the-go specification, but it needs to run in Host role. We have found a few libraries and what not but they seem to only work if the application is host and the device is the peripheral. Any information or leads would be greatly appreciated.
Thanks.
The USB Ports on a typical Windows PC can only talk in Host mode. This means that if your device is directly connected to a PC (including hubs), it has to run in device mode.
There are devices that can talk to 2 USB hosts at one (e.g. some USB<->USB PC connection cables). That could be one solution to your problem, but to me it looks more like you just have to adapt your devices software some bits.

Categories

Resources