Solved

Delphi LAN Problem.

Posted on 2008-06-11
11
343 Views
Last Modified: 2013-11-23
Hello, We have 1 PC with 3 ethernet cards install connected to 3 different networks.

I got an IP address some where on one of my 3 networks, How can I detect using what ethernet card Windows will use to rich the IP address more accurate I want to know the local IP address of the ethernet card on which the remote IP is located.
0
Comment
Question by:S_Warrior
11 Comments
 
LVL 9

Expert Comment

by:Lester_Clayton
ID: 21769048
You wouldn't actually use Delphi to try to figure out what what network card traffic will go from to try to reach a specific IP address, you'd look at your routing table and ascertain that from there.  Delphi does not choose a network interface, that's all based on your winsock layer, but you can choose which interface IP to bind to, if you want it to go through one specific interface.  Bind to the IP address of the interface you want to use, if this is the case.

To view your routing table, open up a DOS box, and then type ROUTE PRINT.  See if your target network is listed, and if it is, it will tell you what the interface IP would be of the outbound route.  If it is not listed, then it will use the default gateway to reach that network host.  I suspect that you will probably find that it's going through the interface which has the default gateway set.
0
 

Author Comment

by:S_Warrior
ID: 21769787
No, No, My application must detect this automatically.
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 21769884
What are the IP addresses of the three network cards inside your PC?

That would be a first big step in helping!

Are all three IPs static or are they dynamic?

Same subnet?

Same Net? (Bad idea).

Some more information is truly needed here I believe.

John

0
 

Author Comment

by:S_Warrior
ID: 21776635
I think u do not understand! I am not trying to find it for my pc I am trying to write an application that will detect it.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 21863318
open a dos box with cmd
and type
ipconfig /all
0
 

Author Comment

by:S_Warrior
ID: 21881352
Geert_Gruwez:this is the most stupid's answer I ever got on EE. read the questions.
0
 
LVL 9

Accepted Solution

by:
alkisg earned 250 total points
ID: 21889318
The function you're looking for is GetBestInterface:
http://msdn.microsoft.com/en-us/library/aa365920(VS.85).aspx

Then you may query the returned interface for its IP, netmask or whatever else you like.
0
 
LVL 4

Expert Comment

by:bjove
ID: 22231033
If IP address you try to access from the PC is in the same subnet with one of your interfaces then windows will use that interface to reach the IP address.
If IP address you try to access from your PC is in different subnet windows will use first adapter in binding order that have default gateway configured.
0
 
LVL 1

Expert Comment

by:Tueblo
ID: 22293331
Hello S_Warrior,

bjove is absolutley right. But I thought you umight need some further information. To check wether an ip address resides in a local area network you have to compare the host part of the ip address provided with the host part of the ip address of one network interface, like (ip_provided and subnetMask_interface) = (ip_interface and subnetMask_interface). You can get the ip addresses and subnet masks of all interfaces using the IP Helper API function GetAdaptersInfo (http://msdn.microsoft.com/en-us/library/aa365917(VS.85).aspx). This adapters info table also includes the configured gateways.

Regards,
Tueblo
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tidtcpserver connection lost handle 2 70
Firemonkey webbrowser scrollbars ? 1 29
Firemonkey android show image from resource ? 1 33
Graphics32 under Delphi 10.1 Berlin 2 36
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now