Search code examples
node.jsnode-modulesgame-makergmlnodejs-server

How to get a clients private IP with Node.js Net Module?


I'm working with GameMaker Studio as clients and NodeJS as the server. Using socket.remoteAddress from within the connection or data event will only return my computer's public IPv4 address, but GameMaker can't connect to that. Is there any way to get the private IP, or to make GameMaker connect using the public IPv4 address? I tried GameMaker's standard and _raw functions, neither of them accept the public IP. Thank you!


Solution

  • Unless the server and client are on a local network the private IP is useless. You want to make sure the ports you are using to connect from the client are opened on the servers side. If it's a local server to the client be aware that some modems don't allow you to port forward to yourself, in that case a local ip would be good. Or a change in your modems settings... If the server and client are on the same machine using 127.0.0.1 as an ip should work. But sure you'll need a lot more research to get this going, hope this helps if you are still needing help!