[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

problem determining local IP address correctly

Posted on 2000-02-29
12
Medium Priority
?
248 Views
Last Modified: 2013-12-03
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.
0
Comment
Question by:nicholso
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 2569730
This is the best method I've rn across:

http://www.caip.rutgers.edu/~arni/ws2/stas.htm
0
 
LVL 1

Expert Comment

by:castorix
ID: 2573080
0
 

Author Comment

by:nicholso
ID: 2573095
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?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:nicholso
ID: 2576866
Thanks for the try, but I can't get the code on that site to work.... any more suggestions?
0
 
LVL 32

Expert Comment

by:jhance
ID: 2577019
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.
0
 

Author Comment

by:nicholso
ID: 2577695
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?
0
 
LVL 32

Expert Comment

by:jhance
ID: 2578025
0
 

Expert Comment

by:CyberBrain
ID: 2578351
The piece of code provided the same functionality as gethostbyname. You can not decide the IP for the internet. Is that right?
0
 
LVL 32

Expert Comment

by:jhance
ID: 2578634
>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.
0
 

Author Comment

by:nicholso
ID: 2581107
OK, jhance, I got it to work now. Thanks.

Post a dummy answer and I'll give you the points.
0
 
LVL 32

Accepted Solution

by:
jhance earned 800 total points
ID: 2581259
Dummy....  (Not you, the answer....)

Glad it worked out.
0
 

Author Comment

by:nicholso
ID: 2581308
thanks again.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question