简体   繁体   中英

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). 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. For context, my app runs in networks that have multicast disabled which is when users fall back to manually entering the IP address.

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? That would allow me to make use of MPC for the MCSession aspect.

Is it possible to set up a Multipeer Connection based on an ip:port rather than having it automatically discovered via multicast?

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.

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. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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