I am currently developing an application on iPad which connects to a client pc on the local network and delivers messages.
I installed a python application at the client after reading the following tutorial:
http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server
It works fine for local connections.
The application opens a port for connection and my iPad application connects using the local IP of the client and the port.
What happens if I want to connect to a public IP?
I tried that and it doesn’t work. I got the client’s public IP from the following site:
http://www.whatismyip.com/
and I used the same python app to open a port.
I presume, that I have to open a port on my router and forward it to the client. But is there a way to do it without having to access settings of my router. I want to achieve instant access, so that the user would not have to worry about settings.
Just like Skype does, or multiplayer games, or other online services. My question is a little bit generic, not specific. Sorry for this. I hope it may help other people also.
Presumeably the machine you are trying to reach is behind a router/NAT device. In other words, it is not directly connected to the Internet.
The router is responsible for deciding what datagrams are allowed to move between the private and public networks, and where they should go.
Skype, games, and online services all initiate their connections from within the private network outward to a server on the public network. Outgoing network traffic triggers a temporary NAT (Network Address Translation) rule which allows datagrams returning from the destination to be routed back to the private host.
But other incoming traffic will be blocked unless you specifically set a rule in the router/NAT telling it where to send the data. How else would it know which address to forward the data to?
So there are only three ways you can communicate with a machine behind an NAT router:
The only way to have full connectivity for a host is for it to have its own properly routed public IP address. Otherwise, the whole point of an NAT is to limit connectivity.