How to get local ip address in code?

How to get local ip address in code?
0.0 0

#1

In Cocos Creator top left hand corner shows the local ip.
How can I retrieve this info by code?

I want to try display that info running on my testing web build.


#2

I don’t think you can do it in a straightforward way, but you could use third-party service like https://l2.io/ to get clients IP. Or make your own server that responds with requesters IP.


#3

There is nothing built-in Cocos2d-x to help you with this. You will need to use 3rd party functionality or go hit up your OS for possible help.


#4

I only want to retrieve this information when doing local testing. For example, my local network ip changes daily because my computer is on a network. So when I m doing debugging I have to change the ip each day on my local computer, it’s not a big thing but when I m seeing the info staring at my face right in the editor I was hoping it’s some editor function I can use in code.


#5

I was hoping there is editor functions because that info is right in the editor for debugging purposes.


#6

The editor can get IP directly from your OS, while game can’t access your OS’s resources so directly.