How can I tell which of multiple network cards is in use using C#?
How can I know which client IP is used for communication to the server in C# if I have multiple network cards in client system (so that there will be multiple IP addresses too) ? I would like to get private IP (not the public IP) .
OR
Please be patient to read the details...
Suppose I have multiple network cards connected to my PC, how can I know which card is used for communication. For example, if I use
ping 192.168.x.xxx
I would like to know which card (and which IP address) used for communication.
The command
netstat
will tell us about the active connections. I am not interested in active connections, but I would like to know which card will be used for next connection. That is, if we use ping
which card (or IP address) will be used ?
How can I get the same IP address using C# (because I would like to do some stuff in WCF which needs endpoint IP addresses )?
For example, I would li开发者_如何学Goke to use the IP(as LocalIP) and port(as ListeningPort) to create the following
net.tcp:// + LocalIP + ":" + ListeningPort + "/Service/ep1;
A reference of the query can be found at... https://superuser.com/questions/304372/how-can-i-tell-which-of-multiple-network-cards-is-in-use
You can connect to remote host using Socket and set specific IP address using Bind method.
精彩评论