简体   繁体   English

根据 IP 地址和端口连接到对等体

[英]Connect to a peer based on IP address and port

I've got an app that supports Bonjour and manually connecting to an IP (all within the same local network).我有一个支持 Bonjour 并手动连接到 IP 的应用程序(都在同一个本地网络中)。 I'm now looking at whether I can use MPC instead and while it obviously would be able to replace Bonjour, I haven't seen anything that allows me to replace the functionality around manually connecting to the IP.我现在正在考虑是否可以改用 MPC,虽然它显然可以替换 Bonjour,但我还没有看到任何可以让我替换手动连接到 IP 的功能的东西。 For context, my app runs in networks that have multicast disabled which is when users fall back to manually entering the IP address.就上下文而言,我的应用程序在禁用多播的网络中运行,这是当用户回退到手动输入 IP 地址时。

I could have the receiving app host a webserver and send a request there.我可以让接收应用程序托管一个网络服务器并在那里发送请求。 Could I create a Peer based on the ip:port combination?我可以根据 ip:port 组合创建一个 Peer 吗? That would allow me to make use of MPC for the MCSession aspect.这将允许我将 MPC 用于 MCSession 方面。

Is it possible to set up a Multipeer Connection based on an ip:port rather than having it automatically discovered via multicast?是否可以基于 ip:port 设置多点连接,而不是通过多播自动发现它?

I'll go with a solution based on NWConnection which uses NWEndpoint and can be created with both IP:port and a Bonjour-established service.我将使用基于NWConnection的解决方案 go 使用NWEndpoint并且可以使用 IP:port 和 Bonjour 建立的服务创建。

If I would've had access to the full Network.framework then I could've used that for both discovery & communication but due to SDK constraints I'll be usingMultipeerConnectivity for the discovery aspect instead.如果我可以访问完整的Network.framework ,那么我可以将其用于发现和通信,但由于 SDK 的限制,我将使用MultipeerConnectivity来代替发现方面。 By providing the device its IP & port when broadcasting the Bonjour service, another device can discover it automatically and then use the extra info to create an IP:port-based NWConnection . 通过在广播 Bonjour 服务时向设备提供其 IP 和端口,另一台设备可以自动发现它,然后使用额外信息创建 IP:port-based NWConnection

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

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