我用扫描通过我的本地家庭网络卓悦1.0
(NET)的服务与 regtype =_http._tcp
:
DNSSDService服务=新DNSSDService();
DNSSDEventManager eventmanager进行=新DNSSDEventManager();
eventManager.ServiceFound + =新_IDNSSDEvents_ServiceFoundEventHandler(eventManager_ServiceFound);
DNSSDService浏览= service.Browse(0,0,_http._tcp,空,eventmanager进行);
当我发现该服务的方法:静态无效eventManager_ServiceFound(DNSSDService浏览器,DNSSDFlags标志,UINT的ifIndex,串服务名,字符串regtype,串域)
调用
然后,在该方法我想使用方法: DNSSDService的getaddrinfo(DNSSDFlags glags,UINT的ifIndex,DNSSDAddressFamily addressFamily,
字符串主机名
,DNSSDEventManager eventmanager进行)
来了解服务的IP地址和端口。
问题的是,我不知道知道什么是 字符串主机名
应,因此我不明白任何结果:**请看:???什么这里?在code **
静态无效eventManager_ServiceFound(DNSSDService浏览器,DNSSDFlags标志,UINT的ifIndex,串服务名,字符串regtype,串域){
Console.WriteLine(浏览器:+浏览器+\ nDNSSDFlags+标志+\ nifIndex+的ifIndex +\ nserviceName:+服务名+\ nregtype:+ regtype +\ ndomain:+域名);
DNSSDEventManager eventmanager进行=新DNSSDEventManager();
eventManager.AddressFound + =新_IDNSSDEvents_AddressFoundEventHandler(eventManager_AddressFound);
DNSSDAddressFamily家庭=新DNSSDAddressFamily();
browser.GetAddrInfo(旗,ifIndex的,家庭,???什么这里???,eventmanager进行);
}
私有静态无效eventManager_AddressFound(DNSSDService服务,DNSSDFlags标志,UINT的ifIndex,字符串主机名,DNSSDAddressFamily addressFamily,字符串的地址,UINT TTL){
Console.WriteLine(----------------------------------------);
Console.WriteLine(发现地址);
Console.WriteLine(----------------------------------------);
}
输出:
浏览器:系统.__ ComObject
DNSSDFlags 2
的ifIndex 32
服务名:AXIS M1011-W - 00408CBEEAE5
regtype:_http._tcp。
域:本地。
全部code:
使用Bonjour;
使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用System.Windows.Forms的;
命名空间WindowsFormsApplication1 {
静态类节目{
///<总结>
///的主入口点的应用程序。
///< /总结>
[STAThread]
静态无效的主要(){
DNSSDService服务=新DNSSDService();
DNSSDEventManager eventmanager进行=新DNSSDEventManager();
eventManager.ServiceFound + =新_IDNSSDEvents_ServiceFoundEventHandler(eventManager_ServiceFound);
// DNSSDService浏览= service.Browse(0,0,_axis-video._tcp,空,eventmanager进行);
DNSSDService浏览= service.Browse(0,0,_http._tcp,空,eventmanager进行);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(假);
Application.Run(新Form1中());
}
静态无效eventManager_ServiceFound(DNSSDService浏览器,DNSSDFlags标志,UINT的ifIndex,串服务名,字符串regtype,串域){
Console.WriteLine(浏览器:+浏览器+\ nDNSSDFlags+标志+\ nifIndex+的ifIndex +\ nserviceName:+服务名+\ nregtype:+ regtype +\ ndomain:+域名);
DNSSDEventManager eventmanager进行=新DNSSDEventManager();
eventManager.AddressFound + =新_IDNSSDEvents_AddressFoundEventHandler(eventManager_AddressFound);
DNSSDAddressFamily家庭=新DNSSDAddressFamily();
browser.GetAddrInfo(旗,ifIndex的,家庭,?????什么这里?????,eventmanager进行);
}
私有静态无效eventManager_AddressFound(DNSSDService服务,DNSSDFlags标志,UINT的ifIndex,字符串主机名,DNSSDAddressFamily addressFamily,字符串的地址,UINT TTL){
Console.WriteLine(----------------------------------------);
Console.WriteLine(发现地址);
Console.WriteLine(----------------------------------------);
}
}
}
解决方案
东西,我会首先检查与_http._tcp记录相关联的TXT记录。从截图中你有_axis-video._tcp选中,就说明你与它相关的MACADDRESS。许多_http._tcp条目记录需要得到它的URL,或所需要的端口/ ip地址。我钻进去,第一。
否则,你可能需要解决MACADDRESS到一个ip地址。我用Google搜索,并配备了 http://www.mostthingsweb.com / 2011/11 /读ARP-项,与-C /
I scanned through my local home network using Bonjour 1.0
(.NET) for services with regtype = "_http._tcp"
:
DNSSDService service = new DNSSDService();
DNSSDEventManager eventManager = new DNSSDEventManager();
eventManager.ServiceFound += new _IDNSSDEvents_ServiceFoundEventHandler(eventManager_ServiceFound);
DNSSDService browse = service.Browse(0, 0, "_http._tcp", null, eventManager);
When I find the service the method: static void eventManager_ServiceFound(DNSSDService browser, DNSSDFlags flags, uint ifIndex, string serviceName, string regtype, string domain)
is invoked.
Then in that method I want to use method: DNSSDService GetAddrInfo(DNSSDFlags glags, uint ifIndex, DNSSDAddressFamily addressFamily,
string hostname
, DNSSDEventManager eventManager)
to get to know service's ip address and port.
The problem is that I do not know know what string hostname
should be and thus I do not get any results: ** Please look at the: ???WHAT HERE?? in the code**
static void eventManager_ServiceFound(DNSSDService browser, DNSSDFlags flags, uint ifIndex, string serviceName, string regtype, string domain) {
Console.WriteLine("browser: " + browser + "\nDNSSDFlags " + flags+ "\nifIndex " + ifIndex +"\nserviceName: " + serviceName + "\nregtype: " +regtype+ "\ndomain: "+ domain);
DNSSDEventManager eventManager = new DNSSDEventManager();
eventManager.AddressFound += new _IDNSSDEvents_AddressFoundEventHandler(eventManager_AddressFound);
DNSSDAddressFamily family = new DNSSDAddressFamily();
browser.GetAddrInfo(flags, ifIndex, family, ???WHAT HERE???, eventManager);
}
private static void eventManager_AddressFound(DNSSDService service, DNSSDFlags flags, uint ifIndex, string hostname, DNSSDAddressFamily addressFamily, string address, uint ttl) {
Console.WriteLine("----------------------------------------");
Console.WriteLine("FOUND THE ADDRESS");
Console.WriteLine("----------------------------------------");
}
Output:
browser: System.__ComObject
DNSSDFlags 2
ifIndex 32
serviceName: AXIS M1011-W - 00408CBEEAE5
regtype: _http._tcp.
domain: local.
Full code:
using Bonjour;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1 {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
DNSSDService service = new DNSSDService();
DNSSDEventManager eventManager = new DNSSDEventManager();
eventManager.ServiceFound += new _IDNSSDEvents_ServiceFoundEventHandler(eventManager_ServiceFound);
// DNSSDService browse = service.Browse(0, 0, "_axis-video._tcp", null, eventManager);
DNSSDService browse = service.Browse(0, 0, "_http._tcp", null, eventManager);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
static void eventManager_ServiceFound(DNSSDService browser, DNSSDFlags flags, uint ifIndex, string serviceName, string regtype, string domain) {
Console.WriteLine("browser: " + browser + "\nDNSSDFlags " + flags+ "\nifIndex " + ifIndex +"\nserviceName: " + serviceName + "\nregtype: " +regtype+ "\ndomain: "+ domain);
DNSSDEventManager eventManager = new DNSSDEventManager();
eventManager.AddressFound += new _IDNSSDEvents_AddressFoundEventHandler(eventManager_AddressFound);
DNSSDAddressFamily family = new DNSSDAddressFamily();
browser.GetAddrInfo(flags, ifIndex, family, ?????WHAT HERE?????, eventManager);
}
private static void eventManager_AddressFound(DNSSDService service, DNSSDFlags flags, uint ifIndex, string hostname, DNSSDAddressFamily addressFamily, string address, uint ttl) {
Console.WriteLine("----------------------------------------");
Console.WriteLine("FOUND ADDRESS");
Console.WriteLine("----------------------------------------");
}
}
}
解决方案
Something that I'd check first is the TXT record associated with the _http._tcp record. From the screenshot you have the _axis-video._tcp selected and it shows you the macaddress associated with it. Many _http._tcp entries record the url needed to get to it, or the port/ipaddress needed. I'd dig into that first.
Otherwise you may have to resolve the macaddress into an ipaddress. I googled and come with http://www.mostthingsweb.com/2011/11/reading-arp-entries-with-c/