iPhone实现设备间通信的最佳方法
在应用程序中实现实时设备到设备通信的最佳方法是什么?我一直在尝试 Apple 推送通知服务,但发现它在实时消息传递方面充其量也不稳定。有没有办法利用套接字来实现此目的,或者我只是坚持使用 APNS?
What would be the best method to achieve realtime device to device communication within an application? I've been experimenting with the Apple Push Notification Service but find it spotty at best for realtime messaging. Is there a way to utilize sockets for this or am I just stuck into using the APNS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您是初学者,请使用 GameKit。
当您对此感到厌烦时,请使用 AsyncSocket。
GameKit 非常简单,孩子也能使用; AsyncSocket 可能是所有平台上所有网络中最漂亮的库 - 非常易于使用。
在这两种情况下,您将首先使用 Bonjour(两行代码)来“查找”另一个设备。
这是完整的解释...
平板电脑(iPad/Android)-服务器通信协议
关键秘密知识GK,你将需要...
客户端/服务器 GKSession
另一个快速摘要...
在 Mac/iPhone 上进行联网的最有效方法?
根据记录,APNS 与您想要实现的目标绝对没有任何关系!完全忘记 APNS。
半径是多少? -----------------------***
请注意蓝牙仅适用于约二十英尺 。 (十米。)
请注意,对于本地 WiFi 连接,您必须连接到同一个本地 WiFi 集线器。 WiFi 集线器的范围可能只有 20 米,例如仅一栋房子和下一栋房子(取决于墙壁的厚度)。
请注意:实际上不可能在几英里之外连接两台计算机(任何类型)。
没有这样的网络设备。 (你也许可以使用“业余无线电”来构建一个,但需要明确的是,这将是一个完全新颖的新研究项目,需要一家大公司数年才能完成。)
绝对没有任何东西可以像这样工作 - 对不起告诉你坏消息。
唯一的两种可能是蓝牙和 WiFi,它们分别只能在大约 20 英尺和 30 英尺范围内工作。
那么如何连接两台远程计算机呢?答案是,通过互联网。
唯一的方法是通过互联网连接。任何现有技术都无法实现“直接”连接。
如果您需要了解有关如何使用互联网连接两台计算机(例如两部 iPhone)的更多信息,您可能需要询问新的技术人员。问题! 您会很高兴知道这非常简单,并且不会给您带来什么麻烦。
请注意,两台 iPhone 都必须具有良好且稳定的互联网连接。如果他们彼此之间的距离超过 30 英尺,连接到 iPhone 的唯一方法就是通过互联网。他们每个人都必须有良好的互联网连接,否则就不可能。
我希望这有助于澄清事情!
If you are a beginner, use GameKit.
When you get sick of that, use AsyncSocket.
GameKit is so simple a child can use it; AsyncSocket is probably the most beautiful library in all of networking on any platforms - incredibly easy to use.
In both cases, you will first use Bonjour (two lines of code) to "find" the other device.
Here is the full explanation...
Tablet(iPad/Android)-Server Communication Protocol
Critical secret knowledge about GK you will need...
Client/Server GKSessions
Another quick summary ...
Most effective way to do networking on Mac/iPhone?
For the record, APNS has absolutely nothing whatsoever to do with what you are trying to achieve! Utterly forget about APNS.
WHAT IS THE RADIUS? -----------------------***
Please note that BLUETOOTH ONLY WORKS over about twenty feet. (Ten meters.)
Please note that for a local WiFi connection, you must both be connected to the same local WiFi hub. WiFi hubs have a range of perhaps 20 meters only, say one house and the next house only (depending on how thick the walls are).
Please note that: IT IS NOT PHYSICALLY POSSIBLE TO CONNECT TWO COMPUTERS (OF ANY TYPE) OVER A COUPLE OF MILES.
There is no such networking device. (You could perhaps build one using say "ham radio" but to be clear it would be a completely novel, new research project that would take a large company years to complete.)
There is absolutely nothing that works like that - I'm sorry to tell you the bad news.
The ONLY two possibilties are Bluetooth and WiFi, and they work only over about 20 and 30 feet respectively.
So how do you connect two remote computers like that? The answer is, via the internet.
The only way to do it is with an internet connection. There is no 'direct' connection possible with any existing technology.
If you need to know more about how to connect two computers (say two iPhones) using the internet, you will probably have to ask a new question! You will be pleased to know it is very easy and will cause you little trouble.
Note that both iPhones MUST have a good solid internet connection. If they are more than say 30 feet away from each other, the ONLY way to connect to iPhones is via the internet. THey must each have a good internet connection, or there is no possibility.
I hope this helps clarify things!
您可以使用 GameKit 的点对点服务(蓝牙)
Gamekit 如何在 iphone 中进行 p2p wifi 连接
You can use GameKit's peer to peer services (bluetooth)
Gamekit how to do p2p wifi connection in iphone
查看 Apple 的 GameKit 框架 GameKit或者查看基于套接字的网络 AsyncSocket,其中还包含 iPhone 演示。
Check out Apples GameKit framework GameKit Or a sockets based networking look at AsyncSocket which also includes an iPhone demo.