简体   繁体   English

服务发现(Win Server,Android客户端)

[英]Service Discovery (Win Server, Android Clients)

I've got a largely working pair of server (Windows) and client (Android) applications that will need to run on a LAN they will pretty much know nothing about until fired up. 我有一对工作正常的服务器(Windows)和客户端(Android)应用程序,它们需要在LAN上运行,在启动之前,他们几乎一无所知。 About the only assumptions I can make are WIFI and DHCP allocated IP addresses. 关于我可以做的唯一假设是WIFI和DHCP分配的IP地址。

I will need a mechanism for the clients to find the server. 我将需要一种机制让客户端找到服务器。 I've got an entire-alphabet-soup of choices but I've not had to do this before, so I'm asking you, the fine people of StackOverflow, for advice. 我有一个完整的字母汤选择,但以前没有做过,所以我想问您,StackOverflow的好人,以寻求建议。

NSD (Network Service Discovery) seems to be the preferred method on Android but seems non-existent on Windows. NSD(网络服务发现)在Android上似乎是首选方法,但在Windows上似乎不存在。 Is there an inter-operable Windows protocol? 是否存在可互操作的Windows协议?

I get the impression that DNS-SD wouldn't work for this without configuring the DNS before my server showed up on it. 我得到的印象是,如果没有配置DNS,DNS-SD将无法在服务器上显示出来。

As all I need to know is the IP of the server, it's very tempting to just make my own multicast group and have the server announce itself way. 我只需要知道服务器的IP,就很容易创建自己的多播组并让服务器声明自己的方式。 Is there a reason not to go with this approach? 有没有理由不采用这种方法?

Too much fuss. 大惊小怪。

The client can determine its own ip. 客户端可以确定自己的IP。 And knows that the ip of the server is about the same. 并且知道服务器的IP大约相同。 Only the last byte group will be different. 只有最后一个字节组会有所不同。

Just make a loop and try to connect a socket with ip addresses 'around' it's own ip address. 只需进行一个循环,然后尝试将套接字与自己的ip地址“周围”连接起来即可。

You will have the server ip within seconds. 您将在几秒钟内获得服务器ip。 Set a small socket timeout value first. 首先设置一个小的套接字超时值。

Android Service Discovery is compatible with Bonjour. Android Service Discovery与Bonjour兼容。

Using Mono.Zeroconf to make the Bonjour calls. 使用Mono.Zeroconf进行Bonjour调用。 At the current time, the code in Mono.Zeroconf works but the distributed binaries do not . 目前,Mono.Zeroconf中的代码有效,但分布式二进制文件则无效 I had to recompile them but it works. 我不得不重新编译它们,但是它可以工作。

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

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