iPhone 中的端口转发
我必须让我的路由器将从服务器(www.server.com:1112)接收到的数据通过某个端口 xxxx 转发到我的 iPhone 应用程序。我不知道。 我的应用程序侦听该端口,但当服务器将数据发送到端口 xxxx 时,路由器拒绝该操作。
我在路由器中进行了手动配置,效果很好。但我不能期望所有用户都这样做,而且我也不能强迫他们进行此类手动配置。任何人都可以通过提供 iPhone 的示例代码来帮助我吗?
提前致谢。
I have to make my router to forward the data received from server(www.server.com:1112) through some port xxxx to my iPhone application. I don't have any idea.
My application listens the port but while server sends the data to the port xxxx, the router rejects that.
I did manual configuration in my router and it works fine. But I can't expect all of the users to do the same and also I can't force them to do such manual configuration. Can anyone help me please by providing a sample code for iPhone.
Thanx in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您所说,您不能指望用户在其防火墙上手动打开端口,但您不能指望他们的防火墙首先会允许这样做。
我建议您最好的选择是使用 uPNP 并让兼容的路由器为您设置端口转发,类似于 BitTorrent。我很幸运地使用了 TCMPortMapper 框架,它在诸如 subethaedit。要无耻地从文档中抄袭,打开端口就像这样简单:
请记住:
As you say you can't expect users to manually open ports on their firewall, but you can't expect that their firewalls will permit this in the first place.
I'd suggest your best bet is to use uPNP and have compliant routers set up port forwarding for you, similar to BitTorrent. I've had luck with the TCMPortMapper framework, and it's used in production in apps like subethaedit. To shamelessly rip from the documentation, opening a port is as simple as this:
Bear in mind: