1. Jens Alfke
  2. MYNetwork
  3. Issues
Issue #12 resolved

Private / Public IP's

Anonymous created an issue


Not sure if this is the right place to ask this (it's not an issue, more of a question). I am using the MyNetwork library on an iPhone app. I got it listening and so far it's really easy (nice job!!). I am trying to see if this library will work for a game I am developing. I need one iPhone to connect to another iPhone over the internet (not just a local network). I see there is a portmapper class in the library, but I am unsure how to use it, or if its the class I am looking for.

I want to be able to have the iPhone listen on an ip for incomming connections, but I think since many of the devices will be running on WiFi, they will return private ip's in most places (192.168.x.x , etc). How can I get the public IP from the device with this library and make sure that the ip traffic maps back to the correct client if they are behind a router?

Sorry if this was asked in the wrong place, but I didn't see a forum. Thanks for the help! I am really having fun with this code!!! -Jeff

Comments (2)

  1. Jens Alfke repo owner

    Use the PortMapper class to attempt to open a public port. Open the TCPListener first, then create a PortMapper giving it the internal port number of your listener, and if it succeeds it will tell you the public address and port number where your service can be reached.

  2. Log in to comment