Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Get Device's IP address

Discussion in 'iOS and tvOS' started by bronxbomber92, May 31, 2009.

  1. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
    How does one go about getting the iPhone's or iPod Touch's IP address?

    Normally this works
    Code (csharp):
    1. Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString()
    but on my iPod Touch this doesn't work - it triggers a SocketException: "No such host is known."
     
  2. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    You usually don't know your own IP address. I'd ping my own server, and have the server return the IP adress to the iphone.