iPhone 聊天应用程序
我尝试使用 socket 编程制作聊天应用程序,并且我正在使用 Chatty 源代码及其在同一网络上完美运行。但不适用于不同网络。
聊天功能适用于不同网络的 iPhone 吗?
我曾尝试在 iPhone 中使用不同的网络进行聊天,但没有成功。
关于 iPhone 不同网络的聊天功能有什么想法吗?
I have try to make chat application with socket programing and I am using Chatty source code and its working perfect on same network. But not work for different network.
Is chatty work for different network iPhone?
I have tried chatty for different network in iPhone but no success.
Any idea about chatty for different network for iPhone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从Chatty的源代码来看,它似乎只是使用IP和端口号来连接到不同的设备,这就是为什么当用户位于不同网络时无法连接的原因。能否连接很大程度上取决于您两台设备的网络配置。
例如:如果您在同一个 wifi 中,它就可以工作,因为设备之间没有防火墙,并且 IP 可达(例如 192.168.xx)。如果您将其中一部手机连接到 3G 网络,它将无法连接到 Wi-Fi 中的另一部手机,但 Wi-Fi 中的手机仍可能能够连接到 3G 中的手机,具体取决于您的职业和情况端口号,以及电话中的网络堆栈是否打开。因此,结论是:这将非常不可靠。
通常,对于这种通信,应用程序依赖于第三方,因此您的两部手机首先连接到始终在互联网上可用的网络服务器,然后网络服务器将消息发送到每个应用程序。这也解决了一个应用程序脱离网络的问题(例如,当您乘坐电梯时)。
From looking at the source code for Chatty, it seems that it just uses an IP and port number to connect to a different device, and that's the reason why you can't connect when users are in a different network. Being able to connect or not will depend a lot on the network configuration you both of your devices have.
For example: it works if you're in the same wifi, because there's no firewall between the devices, and the IP is reachable (192.168.x.x, for example). If you take one of the phones to a 3G network, it won't be able to reach the other one in the wifi, but the one in the wifi might still be able to reach the one on the 3G, depending on your career and port number, and if the network stack is on in the phone. So, conclusion is: this will be highly unreliable.
Usually, for this kind of communication, apps rely on a third party, so both of your phones connect first to a webserver, that is always available on the internet, and the web server sends the messages to each of the apps. This also solves the problem of one app going off the network (when you take an elevator, for example).