通过本地主机上的 bonjour 发布
我有两个应用程序,其中一个运行一个 http 服务器并访问它。我不想对作为客户端的应用程序中的 URL 或端口进行硬编码,所以我想通过 bonjour 发布,
NSString *publishingDomain = @"local.";
NSString *publishingName = @"some";
NSString* type = @"_http._tcp.";
int port = 1234;
netService = [[NSNetService alloc] initWithDomain:publishingDomain type:type name:publishingName port:port];
netService.delegate = self;
[netService publish];
当服务成功发布时,发布代码如下 bonjour 浏览器在服务名称下列出了一堆 ip 地址,但没有它们可用于连接到服务,而我可以使用 localhost:port 和 127.0.0.1:port 来访问 Web 服务器。 Bonjour 浏览器未在列表中将 127.0.0.1 列为 IP 地址。
需要采取哪些不同的措施来解决这个问题?
i've two apps one of them runs an http server and the accesses it. I do not want to hard code the URL or the port in app which is client so I want to publish via bonjour the code for publishing is following
NSString *publishingDomain = @"local.";
NSString *publishingName = @"some";
NSString* type = @"_http._tcp.";
int port = 1234;
netService = [[NSNetService alloc] initWithDomain:publishingDomain type:type name:publishingName port:port];
netService.delegate = self;
[netService publish];
while the service is successfully published bonjour browser lists a bunch of ip addresses under service name but none of them can be used to connect to service whereas I can use both localhost:port and 127.0.0.1:port to access the web server. Bonjour browser does not list 127.0.0.1 as an ip address in the list.
what needs to be done differently to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论