我使用NsdManager注册了服务:
public void RegisterService(string serviceName, int port, Dictionary<string, string> attributes, string serviceType = "_itxpt_http._tcp.")
{
var serviceInfo = new NsdServiceInfo()
{
ServiceName = serviceName,
Port = port,
ServiceType = serviceType
};
if (attributes != null && attributes.Count > 0)
{
foreach (var keyValuePair in attributes)
{
serviceInfo.SetAttribute(keyValuePair.Key, keyValuePair.Value ?? string.Empty);
}
}
NsdManager.RegisterService(serviceInfo, NsdProtocol.DnsSd, new ListenerWrapper(_eventLogger));
}我得到了TXT和SRV记录。SRV记录的格式为inventory._itxpt_http._tcp.local 120 CLASS32769 SRV 0 0 8090 Android-2.local。
如何更改当前格式?我想删除服务名(inventory)后面的点,我想让它看起来像这样:inventory_itxpt_http._tcp.local 120 CLASS32769 SRV 0 0 8090 Android-2.local
发布于 2021-03-08 04:23:17
除了你的问题在这里是离题的,因为它与编程无关之外,你不能“改变”SRV记录的格式。这些记录必须以"_service._protocol“格式作为前缀。
因此,不能将inventory._itxpt_http._tcp.local名称附加到SRV记录,因为它不符合规范(实际上,即使您首先删除inventory,服务部分也不是,因为服务部分通常是IANA服务列表中的一个标记)。有关SRV记录是如何设计、如何工作和如何使用的详细信息和解释,请参阅RFC2782。
inventory_itxpt_http._tcp.local的格式也不正确。
如果你能解释更多你的问题,以及为什么你想要这个SRV记录,因为你显然没有按照设计的方式使用它们,你可能会得到更好的回复,但可能不会出现在这个网站上,除非你从编程问题开始。
https://stackoverflow.com/questions/66517885
复制相似问题