使用 iPhone 进行点对点聊天

发布于 2024-11-17 23:58:10 字数 291 浏览 2 评论 0原文

通过搜索 StackOverflow,我知道这个问题被问了多少次,但我仍然希望有人能告诉我我是否错了……

我正在为 iPhone 创建一个点对点聊天应用程序。我最初的想法是避免使用服务器,所以我想到了 Bonjour。我很高兴编码了很长一段时间,并实现了很多奇特的功能,但两天前我开始使用来自不同子网的两个客户端进行测试,发现客户端无法相互连接!我突然意识到 Bonjour 是用于本地网络的,而 DNS 服务器对于广域服务广播是必需的。我真的需要一台服务器来进行 Internet 点对点聊天吗?是否还有其他不涉及在 iOS 平台上使用服务器的选项?

I am aware of how many times this has been asked based on searching StackOverflow, but I am still hoping someone could tell me whether I am wrong...

I am creating a peer-to-peer chat app for the iPhone. My initial idea was to avoid using a server, so Bonjour came to mind. I was happy coding for quite a while and implemented a lot of fancy features, but two days ago I started testing with two clients from different subnets and found that the clients couldn't connect to each other! I suddenly realized that Bonjour is meant for local networks and that a DNS server is necessary for wide area service broadcasting. Do I really need a server for Internet peer-to-peer chat? Are there any other options that do not involve using a server on the iOS platform?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苦行僧 2024-11-24 23:58:10

我想知道如何在不使用服务器的情况下制作聊天应用程序。有很多廉价的解决方案,亚马逊有自己的服务,谷歌也有。您可以先尝试,甚至无需支付一分钱。

I am wondering how you can do a chat app without using a server. There are many cheap solutions out there, Amazon has its own service, Google does as well. You can try first without even having to pay a cent.

浅浅淡淡 2024-11-24 23:58:10

我从苹果开发者指南中找到了以下内容。这应该可以回答您的问题 -

  1. Bonjour 是否可以在多个子网之间工作?

是的。 Mac OS X 的 DNS 服务发现 (DNS-SD) 的第一个版本集中于单链路网络的多播 DNS (mDNS),因为这是 IP 软件服务最差的环境。从 Mac OS X 10.4 开始,Bonjour 现在使用动态 DNS 更新 (RFC 2316) 和单播 DNS 查询来启用广域服务发现。

I found the following from apple developer guide. This should answer your question -

  1. Does Bonjour work between multiple subnets?

Yes. The first release of DNS Service Discovery (DNS-SD) for Mac OS X concentrated on Multicast DNS (mDNS) for single-link networks because this was the environment worst served by IP software. Starting in Mac OS X 10.4, Bonjour now uses Dynamic DNS Update (RFC 2316) and unicast DNS queries to enable wide-area service discovery.

夏末 2024-11-24 23:58:10

要回答这个问题,唯一的方法是您携带所有可能的参与者及其当前 IP 地址的列表,并且每个可能的参与者每次其 IP 地址发生变化时向所有其他参与者报告。因此,如果您有 100 个可能的参与者,那么当您的 IP 地址发生变化时,您必须告诉其他 99 个人,而这 99 个人也必须在他们的 IP 地址发生变化时告诉您。

Bonjour 可以在 LAN、WAN 甚至 WAN 上运行,但它永远不会在 Internet 上运行。

服务器的作用是让每个端点发生变化时只需要告诉一个端点(服务器)。我的建议是购买一个便宜的互联网主机,具有基本的 PHP / MySQL 功能,并为自己编写一个非常简单的脚本来发布和获取用户身份。

To answer the question, the only way is for you to carry a list of all possible participants, and their current IP address, and for each possible participant to report to all others each time their IP Address changes. So, if you have 100 possible participants, then you must tell 99 others when your IP Address changes, and those 99 must tell you when their IP Address changes.

Bonjour may work on a LAN, a WAN or even a WAN, but it will never work on the internet.

The role of the server is so that each end point only need to tell one end point (the server) when it changes. My advice is get a cheap internet host, with a basic PHP / MySQL capabilities, and write yourself a very simple script to post and get user identities.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文