nicholso
asked on
problem determining local IP address correctly
This one is driving me nuts.... I'm working on a GUI which configures a network element. On connect, I need to write the local IP of the PC the gui's running on to a table on the network element, so it will send state change traps to a certain port on the PC.
Anyway, I'm writing in visual basic and it ordinarily works fine through a VB function to get the local IP address. There is a problem when you have a laptop, for instance, which is configured for a static IP through a ethernet port, but also has a modem. If you try to dial up and get a DHCP address, windows gets confused when I ask for the local IP and always returns whatever the static IP is, even when that interface is not in use (i'm dialed-up and ethernet cable disconnected).
I got some code to call the windows API directly, thinking it was a VB bug, but get the same result.
Does anyone know how to get the correct IP in this situation--I need the DHCP address in order that the traps go to the right location.
Anyway, I'm writing in visual basic and it ordinarily works fine through a VB function to get the local IP address. There is a problem when you have a laptop, for instance, which is configured for a static IP through a ethernet port, but also has a modem. If you try to dial up and get a DHCP address, windows gets confused when I ask for the local IP and always returns whatever the static IP is, even when that interface is not in use (i'm dialed-up and ethernet cable disconnected).
I got some code to call the windows API directly, thinking it was a VB bug, but get the same result.
Does anyone know how to get the correct IP in this situation--I need the DHCP address in order that the traps go to the right location.
If it can help you : http://www.cyberport.com/~tangent/programming/winsock/newbie.html#q3
ASKER
Castorix, thanks, I actually already saw that site and it was sort of helpful but didn't solve the problem.
jhance, I went to that site you mentioned but the .zip was missing necessary .lib files. At any rate I could run the project. Do you have any clues?
jhance, I went to that site you mentioned but the .zip was missing necessary .lib files. At any rate I could run the project. Do you have any clues?
ASKER
Thanks for the try, but I can't get the code on that site to work.... any more suggestions?
And why doesn't it work? It works perfectly for me.
Did you follow the instruction?
Did you even read the article? If you had, you'd know where to find the "missing" lib files.
Did you follow the instruction?
Did you even read the article? If you had, you'd know where to find the "missing" lib files.
ASKER
OK, so I read the article too fast and I didn't see that part. RELAX. I was in a hurry.
So now i'm trying to find the win95 SDK, I couldn't find it at www.microsoft.com. Any clues?
So now i'm trying to find the win95 SDK, I couldn't find it at www.microsoft.com. Any clues?
You can download the WINDOWS SDK from:
http://msdn.microsoft.com/downloads/c-frame.htm?007#/downloads/sdks/
http://msdn.microsoft.com/downloads/c-frame.htm?007#/downloads/sdks/
The piece of code provided the same functionality as gethostbyname. You can not decide the IP for the internet. Is that right?
>The piece of code provided the same
>functionality as gethostbyname.
No it doesn't. gethostbyname is not suitable for this purpose. Try running it on a machine with 2 network adapters and you'll see why.
>functionality as gethostbyname.
No it doesn't. gethostbyname is not suitable for this purpose. Try running it on a machine with 2 network adapters and you'll see why.
ASKER
OK, jhance, I got it to work now. Thanks.
Post a dummy answer and I'll give you the points.
Post a dummy answer and I'll give you the points.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks again.
http://www.caip.rutgers.edu/~arni/ws2/stas.htm