Archived

This topic is now archived and is closed to further replies.

Getting internet address (as opposed to local address)

This topic is 6028 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

O.k. on my computer (and many other peoples) my local address is NOT my internet address. I want to write in the ability to type in an internet address to connect to a game on that computer, but in order to do that I have to know the local internet address, which can be different from the local macine address. How do I get what I am looking for? Jason Mickela ICQ : 873518 E-Mail: jmickela@pacbell.net ------------------------------ "Evil attacks from all sides but the greatest evil attacks from within." Me ------------------------------

Share this post


Link to post
Share on other sites
Are you talking about the loop back address 127.0.0.1? That is provided by the MS loopback driver. When connecting to another computer you do not need to bind the socket to an address. You just call connect() and it should work. If you computer has multiple network cards (multi-homed) it should still work. If you call gethostbyname() to get back a hostent structure and enumerate through the IP address it returns.

If your computer happens to be behind a DSL/cable modem sharing router (software or hardware) then things become more difficult. Your packets get sent to the router (which becomes your default gateway) and get sent to the remote computer. Before sending the data, the router modifies the IP header and replaces your internal IP (from your computer) with the IP address assigned to the cable modem (which normally goes to your computer if you weren''t using a NAT/sharing system). When the remote computer receives data it can send data back, which the router receives. The router remembers where the data came from and sends it back to your computer.

Now, in this situation it becomes nearly impossible to figure out your internet IP address. In reality you don''t need the IP address because the router automatically handles things. You may need to forward a port on the router if it acts as a firewall too.

If this doesn''t answer your question can you explain what you mean between your ''local address'' and your internet address. If you only have one network card and are attached directly to your DSL/cable modem then your local address is the same as your internet address.



Dire Wolf
www.digitalfiends.com

Share this post


Link to post
Share on other sites
I have DSL that feeds into my Linux server, it acts as a gateway to my Win box. It''s address it 90.0.0.2, it only knows it''s gateway address. The problem is, if I am behind a gateway, and the other computer is behind a gateway, I can''t for a connection because I don''t know the internet address of either computer.
I just need something like a server that you can connect to that tells you where you are connecting from, or a way to find out my address.



Jason Mickela
ICQ : 873518
E-Mail: jmickela@pacbell.net
------------------------------
"Evil attacks from all sides
but the greatest evil attacks
from within." Me
------------------------------

Share this post


Link to post
Share on other sites
Dire Wolf is right, you can''t get the IP address of a machine behind a proxy server/firewall (which is the whole point of such a device). Forwarding a specific port is your best bet, as previously stated.

Share this post


Link to post
Share on other sites
One "duct-tape" method is to do a page scrape from http://www.whatismyipaddress.com

Your program could grab the page via a HTTP request and then parse through the results for your Internet IP address.

LostLogic
www.lostlogic.com
Author, Multiplayer Game Programming



Edited by - LostLogic on June 9, 2001 11:44:47 PM

Share this post


Link to post
Share on other sites
alchemar is correct if you are talking about an IP behind a firewall.

If you have NAT working then you could do the screen-scrape method I talked about about and specify the port. That would direct you to the proper machine.




LostLogic
www.lostlogic.com
Author, Multiplayer Game Programming

Share this post


Link to post
Share on other sites