网络服务发现 [英] Network Service Discovery

查看:147
本文介绍了网络服务发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在看制作为Android(客户端)和服务器(Windows)的客户端/服务器应用程序。

I am looking at making a client/server application for Android (Client) and Server (Windows).

该应用的目的是从服务器(PC)的它允许用户扫描网络是与我的C#应用​​程序兼容的设备,然后可以发送消息给和来自客户端和服务器。

The purpose of the app is from the server (PC) it allows the user to scan the network for devices that are compatible with my C# application and then can send messages to and from the client and the server.

我一直在阅读了Android文档,发现网络搜索服务中,机器人
 在 http://developer.android.com/training/connect-devices-无线/ nsd.html

I've been reading the Android documentation and found the Network Discovery Service in android at http://developer.android.com/training/connect-devices-wirelessly/nsd.html.

我是如何工作的理解是,在Android应用程序,用服务的名称,IP地址和端口号,其它设备可以通过连接到它发送一个广播消息。因此,在我的情况下,C#会收到此广播消息,并决定该服务是否是值得我的C#应用​​程序可以支持,如果是这样,那么建立与从广播细节套接字连接到Android设备。

My understanding of how this works is, the android application, sends a broadcast message with the service name, IP and port number that other devices can connect to it via. Therefore in my case the C# would receive this broadcast message and decide whether the service is something my C# application can support, and if so, then establish the socket connection to the android device with the details from the broadcast.

正如我说我已经找到了注册该服务的Andr​​oid开发者的教程,但我无法找到C#怎么能在这找到这个广播消息和都难。

As I say I've found the android developer tutorial for registering the service, but I can't find anything for how C# can find this broadcast message and act upon it.

任何帮助或教程,你可能会是伟大的,因为谷歌并没有发现我什么,我不能完全肯定,如果我在寻找正确的事情。

Any help or tutorials that you may have would be great as Google hasn't found me anything, I'm not entirely sure if I'm searching for the correct thing.

感谢

推荐答案

@greenapps是正确的,服务器应该播出。因此,使用网络服务发现来发现服务通过你的C#的服务正在播出。

@greenapps is right, the server should broadcast. Therefore, use the Network Service Discovery to discover a service being broadcast by your C# service.

Android的 NsdManager 类有这样做的教程。它的工作原理采用基于DNS服务发现,并列出官方规格这里。我相信这是DNS服务发现(DNS-SD)标准。

Android's NsdManager class has a tutorial for doing this. It works using "DNS based service discovery", with the official spec listed here. I believe this is the DNS Service Discovery (DNS-SD) standard.

您的服务器将要播出。你应该能够做到这一点使用这个问题,其中涵盖DNS SRV,DNS-SDS基础之一。

Your server will have to broadcast. You should be able to do this using this question, which covers DNS SRV, one of DNS-SDs foundations.

当然,C#广播服务类型必须将SERVICE_TYPE字符串参数在你的Andr​​oid code匹配:

Of course, the C# broadcast service type will have to match the SERVICE_TYPE string argument in your Android code:

mNsdManager.discoverServices(
    SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);

这篇关于网络服务发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆