开发者

How to set up http server on iPhone behind firewall

开发者 https://www.devze.com 2023-04-12 02:35 出处:网络
I want to develop an iPhone app with a simple IM feature. I am thinking about setting up an HTTP server on开发者_如何学JAVA an iPhone. If the iPhone is using wifi and is behind a firewall, how can I m

I want to develop an iPhone app with a simple IM feature. I am thinking about setting up an HTTP server on开发者_如何学JAVA an iPhone. If the iPhone is using wifi and is behind a firewall, how can I make sure that other iPhone clients can connect to it?


It's not the firewall that will disturb the connection as much it is the NAT.

When you are connected through wireless router to connect the internet you are surfing via NAT. it means you dont really have an extenral IP but once you initiate connection the router will map your intenral IP to one of his externatl ports and for certain time window he will pass connections to you if he will get it to the right port.

That being said, there is no actual way of setting a server behind a NAT unless you can configure port forwarding in the router and internal static IP.

Hope i was clear enough, good luck


I do not really think that you need to get an HTPP server up and running on iPhone to make an application that can send and receive messages (IM). The idea of making one iPhone user to directly connect to one another does not seem right to me since the users will need to know IP addresses of one another to do that.

Interconnectivity between different users of the chat can be solved by making your application communicate via a dedicated TCP port. It is generally advisable to choose ports with a number higher than 1024 since those below are generally found on the list of so-called well-known ports and are used for Web (like port 80), FTP (port 21), SSH (22), DNS (53), etc., it will be the responsibility of the user to make sure the port used by your application is open on the firewall. In order to solve this problem you can actually use port 80 for communication if you find that the port you have selected is blocked. You can do this because you know that this port will not be blocked in most cases. Indeed Yahoo Messenger is reported to use this technique when the firewall blocks the port it uses for communication.

The port should be used by your application to connect to the Web-server that will actually store user credentials, perform authentication, message transmission, etc., and the server should reside on capable hardware to be able to support large number of simultaneous connections. I can suggest using either a VPS (like the one provided by Linode) or a cloud (like Amazon EC2, Google Application Engine, Rackspace).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号