Link to home
Start Free TrialLog in
Avatar of stesherlock
stesherlock

asked on

Getting an internet IP

I'm working on a simple client/server chat program, and the person who's running the server needs to know their IP so they can pass it to their friends to let them know which IP to connect to, so I need a simple way, with as little code as possible, to display a computers Internet IP address in a text box on their form.

Like I said, this is a simple client/server program, and I want the files to be as small as possible, so the answer that uses least code will get the points...
Avatar of ne0
ne0

Add a winsock control

text1.text = winsock1.localIP


Hope This Helps

ne0
Avatar of stesherlock

ASKER

The first method seems to be returning my network IP (192.168.0.1) and not my Internet IP as this project needs. I'll look into the second method now, but like I said, the code needs to be as small as possible.

Thanks.
OK, I've just looked at the second suggestion, but would someone be kind enough to extract JUST these parts from that code?

The part that gives the netbios / username.

The part that gives the INTERNET IP.

I've had a look, and given it a try, but I've not really used API before so I'm not quite sure how to change it.

Thanks.
I'd still rather use the winsock control, if someone knows how I can make it return my Internet IP instead of my LAN IP....
i think u r in lan and using a proxy server
then it is going to broadcast ip and u will get only ur lan ip not ur internet ip
because ur whole network will be visible as one single machine
so winsock is the best shot
ok
best of luck
any there r lot of rpograms which r small and powerful available on net for downloads which does the think u asked for
best of luck
i think u r in lan and using a proxy server
then it is going to broadcast ip and u will get only ur lan ip not ur internet ip
because ur whole network will be visible as one single machine
so winsock is the best shot
ok
best of luck
any there r lot of rpograms which r small and powerful available on net for downloads which does the think u asked for
best of luck
Well, I can tell you what you are thinking is wrong.

I *AM* the proxy server. It's a small home-based peer-peer network, and my brother decided he wanted to get online on his computer, so muggins here had to set it up ;)

Anyway, I've gotten as far as splitting the stuff from the API into seperate IP addresses. Now all I need to do is figure out which is the net IP and which is the LAN.

OK, so it's all gotta be done with code (I could easily pluck out the right addy myself, but if that's all I wanted to do then I'd just use /dns on any IRC server!) and I know that all LAN IPs fall within a few ranges. I know mines set up as 192.168.0.1, but I don't know where the other ranges are, and where they all start or finish.

Whoever gives me them will probably get the points, since there's nothing been posted so far that I didn't find by 'buying' the answer to someone elses question.
Okay, hee's a development. I'm getting a windows socket error 0 when it's compiled into an exe, but it's fine under the vb environment.

Any ideas?
Yet another change. I've gotten over this problem with the socketsinitialise routine, and the other one i can't remember the name of (it was a few hours ago and I'm in college now).

So, now when I run the exe, it gets to the gettheip function happily, but after that I get a divide by 0 error from somwhere. I've searched the code a few times, and the only thing it seems to divide by (backslash does divide too, doesn't it?) is &FF and &F00 (I think, 255 and 256 in hex anywaits...)

Any ideas what's causing these errors, or even better, how to correct them?

Also, I still need to know the ranges for LAN IPs, so i can figure out whichone is the net and which is the lan out of the IPs the function returns...

Thanks for all the help everyone.
an easy way to make your internet ip appear and not your lan Ip

is to use winsock like so

winsock1.connect "www.microsoft.com",80
InternetIP = winsock1.localip

calling it to access the internet will show the real ip address and not just the lan address

Hope it helps

aRTie11
ASKER CERTIFIED SOLUTION
Avatar of GabitaSoft
GabitaSoft

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi all;

If no objections are made in the next 5 days, I will force accept GabitaSoft's answer.

costello
Community Support Moderator @ Experts-Exchange