IP Address
by DIAG · in Torque Game Engine · 05/02/2005 (7:10 am) · 17 replies
Hey there,
Im trying to get the IP Address of my server when Im connected to it locally. I tried using getAddress() but it returns something like IPX:CECECECE:CECECECECECE:52942...(i modified it not to return "local")..does anyone have any suggesstions about how to get your IP Address of a local server using Torque?
Cheers
Damien
Im trying to get the IP Address of my server when Im connected to it locally. I tried using getAddress() but it returns something like IPX:CECECECE:CECECECECECE:52942...(i modified it not to return "local")..does anyone have any suggesstions about how to get your IP Address of a local server using Torque?
Cheers
Damien
#2
05/02/2005 (7:18 am)
But is there any functionality built into torque to check what your ip address is?
#3
05/02/2005 (7:26 am)
But is there any functionality built into torque to check what your ip address is?
#4
I remember seeing a thread on exactly this same issue awhile back, why don't you do a search for IPX and see what comes up.
05/02/2005 (7:32 am)
Yes and it appears to be working fine from your post, looks to me like the issue is in your bindings, for whatever reason your local loopback connection appears to be bound to the IPX protocol. You will need to unbind it, to get a true IP address to show.I remember seeing a thread on exactly this same issue awhile back, why don't you do a search for IPX and see what comes up.
#5
05/02/2005 (7:32 am)
Okay will do. Thanks for your helpful replies!
#6
05/02/2005 (7:33 am)
Oh yeah almost forgot, if you start a dedicated server, then do a query lan, from the options menu (assuming you can run 2 seperate processes in windows), you can get the IP that way as well.
#7
And IP searches return a bunch of posts about Intellectual Property :)
Any idea who was the original author?
05/02/2005 (8:56 am)
I can't find said post, searching for IPX returns no posts :)And IP searches return a bunch of posts about Intellectual Property :)
Any idea who was the original author?
#8
http://www.garagegames.com/mg/forums/result.thread.php?qt=6558
05/02/2005 (9:06 am)
Here's a threadhttp://www.garagegames.com/mg/forums/result.thread.php?qt=6558
#9
What did you use to search for that?
05/03/2005 (6:16 am)
Which doesn't seem to answer the question :)What did you use to search for that?
#10
05/03/2005 (7:19 am)
Google :)
#11
05/04/2005 (1:59 am)
Does anyone have any more suggestions? it's really bugging me!
#12
A common headache with server admins is that a game server doesn't take this into account and they have to beg and plead with the developer to add some way to limit the game to use a specific NIC/address. For example, if your server is also a LAN gateway, you need the game to bind to the external NIC but not the internal one.
05/07/2005 (11:40 am)
Consider also that there may be multiple addresses. You have at least your loopback address (127.0.0.1, for the "virtual" NIC that every IP-capable machine has), plus an IP address for every physical NIC, plus possible IP addresses for "aliases" for those NIC's. It's not that uncommon in servers to have more than one address associated with a NIC.A common headache with server admins is that a game server doesn't take this into account and they have to beg and plead with the developer to add some way to limit the game to use a specific NIC/address. For example, if your server is also a LAN gateway, you need the game to bind to the external NIC but not the internal one.
#13
05/07/2005 (10:57 pm)
With Torque, you can specify what IP you want it to bind to.
#14
Just incase someone stumbles on this like I did :)
05/07/2008 (10:38 am)
And.... that pref is called $Pref::Net::BindAddress!Just incase someone stumbles on this like I did :)
#15
I'm assuming you want it so you can let various game clients talk to each other.
If you just want to give it out to people so they can connect to you from the same LAN, then you need to use something like ipconfig or ifconfig, or C++ Network API calls -- torque can't do that directly. And of course you have the issues of multiple NICs as Kenneth mentioned.
Alternatively you can use a service discovery system like ZeroConf or UPnP to let clients browse for you on the LAN, but that's going to take some C++ work to add to Torque.
If you want to give it out to people on the internet, so they can connect to you, then the addresses returned by ipconfig or ifconfig are usually not the right ones, since most computers sit behind some kind of router that acts as a NAT (Network Address Translation) device. That is, they have an address that only the NAT device and other devices on the LAN can talk to -- something like 192.168.0.1, and then the NAT has a single public IP address on the internet. If that's the case, even if you used some external reflector like showmyip.com/, you'd still need to set up a routing so that the NAT device knows which device to route an incoming connection to. Usually this is done by manually configuring a static route or (D-link calls them Virtual Servers), but there are ways that you are supposed to be able to programatically set up temporary routes by talking to the routers. I have no ideal how widely those protocols are supported.
Or, you can do it the way Torque is built to, by having a well known Master Server publicly accessible on the internet, addressed by a known host and domain name. Clients look there to get the list of games they can connect to, and games that want to act as servers connect there to make their availability known.
05/07/2008 (9:08 pm)
The answer of how to get your IP address varies with the use you want to put it to. I'm assuming you want it so you can let various game clients talk to each other.
If you just want to give it out to people so they can connect to you from the same LAN, then you need to use something like ipconfig or ifconfig, or C++ Network API calls -- torque can't do that directly. And of course you have the issues of multiple NICs as Kenneth mentioned.
Alternatively you can use a service discovery system like ZeroConf or UPnP to let clients browse for you on the LAN, but that's going to take some C++ work to add to Torque.
If you want to give it out to people on the internet, so they can connect to you, then the addresses returned by ipconfig or ifconfig are usually not the right ones, since most computers sit behind some kind of router that acts as a NAT (Network Address Translation) device. That is, they have an address that only the NAT device and other devices on the LAN can talk to -- something like 192.168.0.1, and then the NAT has a single public IP address on the internet. If that's the case, even if you used some external reflector like showmyip.com/, you'd still need to set up a routing so that the NAT device knows which device to route an incoming connection to. Usually this is done by manually configuring a static route or (D-link calls them Virtual Servers), but there are ways that you are supposed to be able to programatically set up temporary routes by talking to the routers. I have no ideal how widely those protocols are supported.
Or, you can do it the way Torque is built to, by having a well known Master Server publicly accessible on the internet, addressed by a known host and domain name. Clients look there to get the list of games they can connect to, and games that want to act as servers connect there to make their availability known.
#16
1) You have multiple externally available addresses on the machine
2) You are running the servers on the same ip address as the master server. When you do this, the servers would normally report your IP address as the loopback local address 127.0.0.1. Which means the client see 127.0.0.1 in the server list! So specifying a bind address gets you around the issue.
05/08/2008 (2:46 am)
All those are right :) The reasons why you would need to bind/specify a specific address are:1) You have multiple externally available addresses on the machine
2) You are running the servers on the same ip address as the master server. When you do this, the servers would normally report your IP address as the loopback local address 127.0.0.1. Which means the client see 127.0.0.1 in the server list! So specifying a bind address gets you around the issue.
#17
07/08/2008 (3:39 pm)
Regarding the NAT discussion, I seem to be having problems with hosting a multi-player game from behind a NAT device. I'm on DSL which goes to a small wireless router. All the computers on my local network return the same IP address from the reflector services. I can start up the hosted server game but I see in the other computer's TGE client console.log that the client is trying to ping the host but the pings fail. So the server doesn't show up in the list. Is this a common problem? Any way around it?
Torque Owner Dreamer
Default Studio Name
Windows, either ipconfig or winipconfig depending on your version.
If you just need to connect to your local server, 127.0.0.1 is always a pretty good bet.