iOS 中通过 wifi 的点对点网络

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15364876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 22:41:04  来源:igfitidea点击:

Peer-to-peer network over wifi in iOS

iosiphonenetworkingmultipeer-connectivitypeer

提问by Andrew

I've been at this for a few days now, and can't seem to find a solution. I want to create a peer to peer network over wifi on iOS. All open source code seems to be supporting running a server or being a client, but there's no code built to support being both - a peer. Is anybody aware of a way I can do this?

我已经在这几天了,似乎无法找到解决方案。我想在 iOS 上通过 wifi 创建一个对等网络。所有开源代码似乎都支持运行服务器或作为客户端,但没有构建代码来支持两者 - 对等。有人知道我可以这样做吗?

回答by darrinm

iOS 7 adds the Multipeer Connectivity Frameworkfor exactly this purpose.

iOS 7正是为此目的添加了多点连接框架

回答by Mr Rogers

Have you thought of using Apple's GameKit framework? I've used it in the past for some simple communication between devices. It's really simple and can get you out of the gate quickly. Thislooks like a good tutorial.

你有没有想过使用苹果的 GameKit 框架?我过去曾将它用于设备之间的一些简单通信。这真的很简单,可以让你快速走出大门。 看起来是一个很好的教程。

回答by naeemjawaid

I think Open Peeris the right solution. It provides real direct peer-to-peer connection between devices without the need of a centralised server. Check out this introductory video.

我认为Open Peer是正确的解决方案。它提供了设备之间真正的直接点对点连接,无需中央服务器。观看此介绍视频

回答by cleverbit

You cannot create a wi-fi network programmatically in iOS using current APIs. GameKit offers some APIs to do so over bluetooth however.

您无法使用当前 API 在 iOS 中以编程方式创建 wi-fi 网络。然而,GameKit 提供了一些 API 来通过蓝牙进行操作。

If you wish to implement a custom solution using CocoaHTTPServer, be aware that you will still not be able to create a direct wi-fi connection, you will simply be able to connect devices on the same (pre-existing) wi-fi network.

如果您希望使用 CocoaHTTPServer 实现自定义解决方案,请注意您仍然无法创建直接的 wi-fi 连接,您只能连接同一(预先存在的)wi-fi 网络上的设备。

Ad-hoc peer to peer Wi-Fi (such as 802.11s) in iOS is still a few years off. Maybe iOSX ;)

iOS 中的点对点 Wi-Fi(例如 802.11s)还需要几年时间。也许 iOSX ;)

回答by JuJoDi

iOS supports the Multipeer Connectivity frameworkwhich enables iOS devices to talk to each other over Bluetooth, infrastructure (with a router) WiFi, or P2P.

iOS 支持Multipeer Connectivity 框架,该框架使 iOS 设备能够通过蓝牙、基础设施(带有路由器)、WiFi 或 P2P 相互通信。

It does not, however, provide a way to explicitly use P2P. There is a layer of abstraction away from how any of a device's peers (other iOS devices) are connected, and it does not currently allow for non-iOS devices to be connected.

但是,它没有提供明确使用 P2P 的方法。设备的任何对等设备(其他 iOS 设备)的连接方式有一个抽象层,并且目前不允许连接非 iOS 设备。