|
-
Dec 8th, 2006, 12:22 PM
#1
Thread Starter
Member
How do I get my internet IP?
Hi
I've been trying to figure out how to get my internet IP Address so that a computer over the internet can connect to my computer. Anyone know how to get the IP Address?
Thanks
-
Dec 8th, 2006, 02:34 PM
#2
Re: How do I get my internet IP?
I can think of two obvious ways.
One involves "asking" the NAT device via one of its admin services. Some will allow a simple Telnet-style connection, almost all allow HTTP queries via port 80 from internal hosts. Either way your application will need to know (a.) that there is a NAT device present and (b.) how to talk to it.
The other involves an external service of some sort that will echo back the public IP address when queried. Many dynamic DNS providers offer this but I hesitate to list a URL because I'm sure they don't want non-customers banging away at their servers.
Another possible method might be to perform a "traceroute" style operation that may come back with what you need, but fishing it out might be problematic. And perhaps the info you need isn't even returned... it isn't displayed as part of a standard traceroute utility's report anyway.
I hope this helps. If not maybe someone else can offer a better solution.
-
Dec 8th, 2006, 05:17 PM
#3
New Member
Re: How do I get my internet IP?
Sorry Guys, I'm complete new to this fantastic forum and a kind of newbie in VB programming.
Is there any problem to involve Winsock to get your local IP?
Unless i have not understand well, Winsock looks fine for me....
Regards
George
-
Dec 8th, 2006, 06:06 PM
#4
Re: How do I get my internet IP?
Yes, winsock can do it but if you are behind a router then that will probably return the public router ip.
Go to http://whatismyip.com to determine the routers IP to check against.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 9th, 2006, 10:34 AM
#5
Re: How do I get my internet IP?
If you're on a network, Winsock.LocalIP will return your local (network) IP, ie:
192.168.0.1 or whatever it may be.
If you have no router/hub, then it should return your external IP.
The best bet would be like RobDogg said and get your external IP from a remote host like showmyip.com
-
Dec 10th, 2006, 07:44 AM
#6
Member
Re: How do I get my internet IP?
Hey this might wrap it up for you. Its for Visual Basic 6. I used it to find my IP. It finds it via winsock but if your behind a router, then it will not return your external IP.
http://support.microsoft.com/kb/160215
Last edited by evan29; Dec 13th, 2006 at 04:23 AM.
-
Dec 10th, 2006, 12:00 PM
#7
Re: How do I get my internet IP?
I your only worry is to have the program determine the local IP address then yes, checking via a Winsock control or the Winsock API works fine.
Otherwise (as in the case where your program may be running on a machine behind a NAT router) you'll probably have to query either the router or an external machine. Either way you'll need to know how to do the query and how to parse the IP address from the response.
I'm not aware of any standard universal way of doing this. Your program needs to either be very aware of the router or very aware of the specific host to be queried.
-
Dec 10th, 2006, 01:27 PM
#8
Re: How do I get my internet IP?
@RD,
http://whatismyip.org is easier to parse. (A simple URLDownloadToFile will do. But you need to clear browser cache first, in case of dynamic IPs.)
Last edited by iPrank; Dec 10th, 2006 at 01:38 PM.
-
Dec 10th, 2006, 01:51 PM
#9
Re: How do I get my internet IP?
Oh, there are sites returning stuff easier to parse than that:
Code:
<html><head><title>Current IP Check</title></head><body>Current IP Address: 20.20.20.20</body></html>
The real issue is what would you even do with it once you had it?
Let's say you're trying to make a distributed game program. One guy starts up and plays "server" and three other guys start up to play as "client."
They all use some incantation to figure out their public IP addresses.
Ok, now they know their own IP addresses. But they have no idea what the IP address of any of the other guys is, so nobody can connect to anyone else!
-
Dec 10th, 2006, 04:59 PM
#10
Re: How do I get my internet IP?
 Originally Posted by dilettante
Ok, now they know their own IP addresses. But they have no idea what the IP address of any of the other guys is, so nobody can connect to anyone else!
That's the whole idea of having a server program in the first place.
They all connect to the server. The server is in charge of relaying packets back to the clients.
How do you think instant messenger programs (yahoo, MSN, etc.) work? Or games?
-
Dec 11th, 2006, 11:09 AM
#11
Re: How do I get my internet IP?
I guess I wasn't clear. I was sort of questioning the point of this whole thread:
Why figure out your own address from within the program? The other end will need it, or you'll need his, but knowing your own doesn't help much. If you're just going to call him on the phone and tell him you can use a plain old web response from one of those sites listed and read it off the screen.
-
Dec 11th, 2006, 06:57 PM
#12
Re: How do I get my internet IP?
Oh I see what you're saying. 
Well, there are alternatives, such as retrieving the IP, and then posting it onto a webpage (this could be done automatically).
The other clients could get the server IP from the webpage.
-
Dec 11th, 2006, 07:00 PM
#13
Re: How do I get my internet IP?
True that could be done. Or one or both people might register for a free dynamic DNS name at one of the many providers. Of course that means running an update client, but some routers have one built in and the PC-based ones are free.
-
Dec 18th, 2006, 04:36 PM
#14
Lively Member
Re: How do I get my internet IP?
Why cant they just make a TCP connection with the server first which doesnt require the IP address of the client needed. Then the TCP connection sends the IP address as Data to the server and then the server connects to the IP address and also sends it to other clients for making a connection.
 Originally Posted by DigiRev
Oh I see what you're saying.
Well, there are alternatives, such as retrieving the IP, and then posting it onto a webpage (this could be done automatically).
The other clients could get the server IP from the webpage.
-
Dec 18th, 2006, 06:01 PM
#15
Re: How do I get my internet IP?
you can't connect to a server unless you know either the IP and port, or the domain name (if it has one) and port.
You can however, connect to your network machines using their computer name and port.
What you need to do is have a central server which all the clients connect to. Have it post the server IP to a webpage, then the clients can download the IP, then connect to it. They can then communicate with the other clients via the server. Thats how the messenger apps work (apart from storing the IP on a page, the big messenger apps have a domain name for the server, e.g. messenger.msn.com)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|