Isn't there a way to know what is my IP address? This would be specially helpful for direct ip connections, where the server machine creates a server that displays his IP address and Port, and he could then tell it to someone via MSN or whatever and he would connect. Regards, Afonso
there are several websites that display all sorts of information about your connection and among others your ip address, like http://www.ip-adress.com/. Or do you mean from inside Unity?
Inside Unity, of course. I think that something like Network.addresses with all of your ip address would be handy. Am I the only one thinking this?
I agree, I was looking for this the other day as well. Would be handy just to put up on the GUI to tell others on the LAN/'Net. I ended up using the following code with a WWW class as a coroutine. Code (csharp): function CheckIP(){ myExtIPWWW = WWW("http://checkip.dyndns.org"); if(myExtIPWWW==null) return; yield myExtIPWWW; myExtIP=myExtIPWWW.data; myExtIP=myExtIP.Substring(myExtIP.IndexOf(":")+1); myExtIP=myExtIP.Substring(0,myExtIP.IndexOf("<")); // print(myExtIP); }
You can use: Network.player.ipAddress http://unity3d.com/support/documentation/ScriptReference/NetworkPlayer.html This is what I'm using to display the IP address of the LAN server once it has been started... so that the user can shout it across the room to their mates so they can join the game... :wink: Cheers.
Thanks, the post was before 2.0.2, which introduced Network.player :wink: Now, besides one odd problem when we connect to the facilitator with a specific modem configuration, and the endian issue on PPC with externalIP being reversed, both of which larus, already knows, it works just fine.
that's ok I figured you would have figured it out. i just posted a solution for others in the future if they ever search on that topic. :wink: Cheers.
Hi, Many free online sites provide these services.I use Ip-details.com for my site. It is reliable and also fast. You can also have Your Viewers IP Address, and IP Address details(country, ISP, address, etc.) displayed on your website by just copying the code from this site on your webpage.
What if my pc is connected to multiple networks at the same time? How to get ips of all of them? (for instance 1 for internet, 1 for hamachi, 1 for local network virtual router etc.)
NetworkTransport.GetConnectionInfo will return ip and port of peer connected to you, than you can use or send this information... The reason why we not report local address is: (1) you can be natted (2) you can belong more than one lan...
Thanks for a prompt reply, I am trying to get a list of available hosts in local network (while ignoring myself), I am using LLAPI broadcasting as you have explained here: http://forum.unity3d.com/threads/ho...ry-with-networktransport.323525/#post-2099741 Since one device can be sender and receiver at the same time, it may receive its own broadcasts. I wanted to ignore these (in order to prevent devices from trying to connect to themselves) by checking if the IP of broadcasting source is one of my device's IPs. If this is not possible, then the only trick that comes to my mind is to include MAC in the bradcast message and check this instead. Or is there any better way to check if a received broadcast message is coming from my own device?
I would say random 32 (64 or guid) value will be enough (and more simple). But if you are still worrying after connect you can send additional message to prevent auto-connect make sense?