网络设备发现网络设备、发现

2023-09-05 08:25:52 作者:傲世あ君临天い

有关我的Andr​​oid应用程序,用户需要连接到某个地方会在同一个局域网上托管的服务器。有可能是托管在同一局域网中的多台服务器。为了方便用户,我会扫描当前网络的Andr​​oid设备连接,然后列出所有具有在其上运行,而不是让用户输入的IP给电脑服务器网络设备手动。

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.

我是相当新的网络,以及一些搜索后,我发现,我将不得不使用多播DNS查找或UDP广播来检测其他设备。我还发现一个不错的库称为jmDNS,但我发现极少数的文档和示例code就可以了。可能有人点我在正确的方向是什么,我试图做救我浪费的时间(主要是,如果我在正确的轨道上)?我假设我将不得不修改我的服务器有点广播它的存在?它的工作原理完全如预期,如果我输入的IP手动插入我的应用程序的配置页面。此外,这只是需要发现Windows计算机,不知道的事项。先谢谢了。

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.

推荐答案

嗯,jmDNS是,你可以用你设置一个完整的Java库。它可以用来braodcast您服务,其他客户端可以搜索。

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对Windows服务是有点棘手,但它绝对有可能。更简单的方法,我想说的是使用jmDNS广播和发现为您的服务器和客户端。

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.