简体   繁体   English

在LAN Java / Android中查找确切的设备

[英]Finding exact device in the LAN Java / Android

I'm developing a Java application which should listen on specific port on computer using Sockets. 我正在开发一个Java应用程序,该应用程序应该使用套接字在计算机上的特定端口上侦听。 The another app, which will run on Android device connected to the same WiFi, should find this computer with my Java program. 另一个应用程序(将在连接到同一WiFi的Android设备上运行)应与我的Java程序一起找到这台计算机。

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(); 我已经使用InetAddress.getByName(ipAddress).isReachable();在小型LAN(所有设备都连接到192.168。*。*的地方)上进行了InetAddress.getByName(ipAddress).isReachable(); but in the bigger network (like eduroam or my school WiFi) I'm not able to scan whole network. 但是在较大的网络(例如eduroam或我的学校WiFi)中,我无法扫描整个网络。

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. 我不确定我是否了解您的整个系统要求,但是我认为您可以在托管站点(例如this )上创建一个非常小的数据库,并使您的PC定期将其专用IP地址上传到该数据库。

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. 然后,当您需要连接到Android设备上的PC时,您查询数据库并确定PC的当前地址,然后连接到该设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM