for example when I’m connected to Internet, it retrieves
my LAN IP address… not my public Internet address…
Do you have a machine with two NICs installed in it - one being the public
IP address and one being the private (translated IP)? If so, I don’t have
an answer for you, here. But in either case, how would you know what the
public NIC is on all machines anyway?
If you have a machine that’s behind a NAT based system, there is simply no
way for your machine to know the public IP address, nor is it going to be
reachable from the outside world unless you do some sort of bizarre port
translation on the NAT machine. It is possible to get to machines on a
local network from the outside world through a NATd network, but it
requires specific configuration of the NAT server to allow it.
–>Neil-------------------------------------------------------------------------------
Neil Bradley “Your mistletoe is no match for my T.O.W. missile!”
Synthcom Systems, Inc. - Santabot - Futurama
ICQ #29402898
Your written English is very good. No need to apologize for it.
I understand your situation. Everyone who has ever written a networked
game faces the same problem. The problem I was pointing out is that even
if you get the machines IP address it might not be the public IP address
of the computer. The machine I am sending this from has and IP address
of 192.168.1.5. Any code, even things like ipconfig, that you can run on
this machine will tell you that. But, that is not the public IP address
of the computer. In fact, it is a none routable address that is only
valid on my LAN. The actual IP address is very different.
I have a hardware fire wall that also does address translation. That way
there is no way for an outside computer to directly contact computers on
my LAN. (OK, I use port forwarding to send email to the email server and
web requests to the web server.) So, if I ran you program as a server,
no one can contact me. I do that to protect my network from bad guys on
the net. It may only be my home network, but I protect it as best I can.
When a computer on my LAN contacts another computer the IP address it
uses as the source address is translated into a real IP address. The
outside world sees the real address, not the 192.168.1.* address that my
PCs see. So if your program displays my IP address, and I send that to
my friend to connect to. He will not be able to connect.
So, that doesn’t help you at all. Try this, there are a number of web
services out there that will tell you your IP. For example:
Provide a list of these for your players to use. Or, you can even have
your program contact one of these sites and get the information you
need. Or, you can write a little server, it doesn’t have to be a web
server, that your players can contact. Your server would just echo back
the IP address of an incoming connection. And, use a service like dyndns.com to make up for you lack of a static IP. They can even let you
have URL like mygame.game-server.cc
Think about it.
Bob Pendleton
P.S.
Bad old joke on the subject of speaking several languages:
What do you call someone who speaks three languages:
- Trilingual.
What do you call someone who speaks two languages:
- Bilinqual
What do you call someone who speaks only one language:
- American…On Thu, 2004-04-15 at 14:18, SkunkGuru wrote:
On Sat, 2004-04-10 at 14:19, Olivier Fabre wrote:
On 10/04/2004, SkunkGuru, you wrote:
I’d like to show the player is local IP address… any idea ?
I don’t know what you want the IP address for. But, it might not be as
useful as you think it is.
well… my little game is made up by a player that start up the game in
server mode (waiting for the connection) and the other player that
start up the game in client mode (connecting to the other computer).
I would like to show the player with the server version, which
public IP address is using… so he can tell this IP to the other
player that needs to connect… I think that not all the people
is able to see his IP address… and this can be more useful
than some txt file that says “open command prompt, type ipconfig…”
or “open a console, type ifconfig…”
I know that a possible solution could be a public web server…
where all the players can meet… so the server can estabilish
a connection between the players… (like The Microsoft Zone)…
but I don’t have a web server or a static IP addess…
and I can’t set up a server for a little game… but if a player
wants to play via Internet and he don’t knows how to retrieve
is public IP address… so I’d like to show it…
I hope it’s a bit more clear, now…
Sorry for my bad English… I hope you understand me…
hum, if the goal is to connect players, may be a public web server could help
your game :
On your public personnal website (a lot of isp give you at least some web
space, if not, change! ), you could create a php script (say : myisp.com) which sends in
response something like :
192.168.0.1
(replace 192.168.0.1 with whatever ip the client has).
Your game would send a request to the web server on this page and the web
server would send back the referee's ip as shown above. The web server knows
the ip of the "thing" that is connected to him, it can send it back to you.
Connecting to a specific web server, with a specific url, and retreiving a
simple specific response formated for you (and by you) is not difficult to
implement .
Moreover, if your isp is kind enough to gives you some web space, php
scripting and a mysql database backend, you could extend this to maintain a
live list of players with their IP, the time of their connection, etc and use
this in your game to present a list of living game servers, with their ip to
the game user. Then the user would choose a game server, and directly connect
(peer to peer mecanism) to the other IP, where your game running on another
computer is waiting for connection… The public web server would not connect
players , but only maintains informations about players. Your game would be
able to use those informations via standard http request / response
mecanism.
Only my 2 cents.
[…]
I know that a possible solution could be a public web server…
where all the players can meet… so the server can estabilish
a connection between the players… (like The Microsoft Zone)…
but I don’t have a web server or a static IP addess…
[…]On Thursday 15 April 2004 19:18, SkunkGuru wrote:
for example when I’m connected to Internet, it retrieves
my LAN IP address… not my public Internet address…
Do you have a machine with two NICs installed in it - one being the public
IP address and one being the private (translated IP)? If so, I don’t have
an answer for you, here. But in either case, how would you know what the
public NIC is on all machines anyway?
I have a PC with an ethernet card (lan address: 192.168.0.5);
I have a adsl modem to connect to internet… (internet address:
dynamic assigned ip, for example: 82.48.24.xxx)
I’d to like find out the 82.xxxxxx address… if the player wants
to play my game over Internet… I think he always knows is
lan address (or at least he knows his computer name to resolve).
So if the client wants to play on lan, he must know the server lan ip
or the server computer name, and when he plays over internet,
I show his internet ip address…–
Bye!
Skunkguru.
… you could create a php script (say : myisp.com) which sends in
response something like :
192.168.0.1
(replace 192.168.0.1 with whatever ip the client has).
PHP is not limited to HTML, it might be easier to just return a text
file with
192.168.0.1
and nothing else. Check the header changing PHP functions for how to
change the MIME-type.
IP address and one being the private (translated IP)? If so, I don’t have
an answer for you, here. But in either case, how would you know what the
public NIC is on all machines anyway?
I have a PC with an ethernet card (lan address: 192.168.0.5);
I have a adsl modem to connect to internet… (internet address:
dynamic assigned ip, for example: 82.48.24.xxx)
How is the DSL modem connected to your computer? Is the DSL modem
providing the network address translation? If it is, you have no way of
finding out the public IP address.
The only way you’ll know is if you have a dedicated LAN adapter in your PC
for your WAN and your PC is providing NAT.
–>Neil-------------------------------------------------------------------------------
Neil Bradley “Your mistletoe is no match for my T.O.W. missile!”
Synthcom Systems, Inc. - Santabot - Futurama
ICQ #29402898
The only way you can get it is with through a server in the Internet.
Somebody already mentioned this and it really is the only way. Besides
some ISP’s simply expires the ip lease very fast if the conncetion is
not used and thus the IP can change very often. My ISP doesn’t and
because I have an old computer as NATing firewall and the IP have
stayed same about a year now. Although the NAT machine has be turned
off for days even. The best way is to recommend the player to get their
ip from some of the already available pages in the Net, or provide one
of your own if possible. Better way is to use the dynamic ip mapping
companies which give possibility to dynamically update the ip of your
machines domain address I for example have my machines hooked through www.no-ip.com’s service. The reason I hook every of my machines is that
I can transparently cary them outside the firewalling NAT and the
domain is still valid. The trick is to use the same base domain in the
LAN so my lans dhcp gives the same no-ip.info base domain to every
machine so that the in lan routing works correctly. This is very
convenient if one owns a laptop.On Thursday 15 April 2004 21:02, SkunkGuru wrote:
for example when I’m connected to Internet, it retrieves
my LAN IP address… not my public Internet address…
Do you have a machine with two NICs installed in it - one being the
public IP address and one being the private (translated IP)? If so,
I don’t have an answer for you, here. But in either case, how would
you know what the public NIC is on all machines anyway?
I have a PC with an ethernet card (lan address: 192.168.0.5);
I have a adsl modem to connect to internet… (internet address:
dynamic assigned ip, for example: 82.48.24.xxx)
I’d to like find out the 82.xxxxxx address… if the player wants
to play my game over Internet… I think he always knows is
lan address (or at least he knows his computer name to resolve).
So if the client wants to play on lan, he must know the server lan ip
or the server computer name, and when he plays over internet,
I show his internet ip address…
I’d recommend you to you NET2 ontop of SDL_net, as it is higher
level/easier to use: it simply uses the SDL-event system to
send events when some packages arrive etc. Also, I think it
is at least as fast as the SDL_net library, due to his replacement
of the SDL_event structure & routines. Best of all, it has
great documentation:
On the Windows XP box I’m at right now, it’s
C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS but I vaguely recall it being in
a different location on Windows 98.
localhost is always 127.0.0.1 whatever you ve got in network configuration
( internet connection, several lan cards )
they are all called interfaces.
u can use the winsock directive to get your isp adresse, but there MUST
exists networking librairies ( or exploits ) to check all the interfaces,
then all the configurations they have ( ip, netmask, gateway and so on )
those exploits / lib exists and I guess there are a lot of them free and
working on all OSes.