From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to specify 2nd network card to TCP open and write?

TCP-Open does not have an option to choose which network card to use. It only has an open to connection but not an open from connection to enter. Is there anyway to select the second network card instead of letting the computer to choose?
0 Kudos
Message 1 of 6
(3,515 Views)

I believe that the network adapter is chosen based on the IP address you give the function.

I'm not sure what happens if you give it a machine name instead of an address.


___________________
Try to take over the world!
0 Kudos
Message 2 of 6
(3,508 Views)
Only the TCP-Listen allows the user to choose which network adapter to listen. The TCP-Open is require to open an connection to write to and it only has an input on where to connect to but not which network adapter to connect from.
0 Kudos
Message 3 of 6
(3,502 Views)

I know that. Read the reply again - I believe the adapter is selected based on the address that you do give the function (normally different adapters have different settings, like the subnet mask etc., and this should allow the OS to select a specific card). Note - the OS does this, not LV.

I believe that if the address is not specific to an adapter, the OS will take the adapter with the highest priority. I think there is a way to play with the adapter priorities (at least in Windows) and if you search here, you might even be able to find VIs which will do this.


___________________
Try to take over the world!
0 Kudos
Message 4 of 6
(3,488 Views)


@pwrdesoto wrote:
Only the TCP-Listen allows the user to choose which network adapter to listen. The TCP-Open is require to open an connection to write to and it only has an input on where to connect to but not which network adapter to connect from.

 

tst is completely right. If you have two network cards they usually have different subnets that should not overlap. If the desired target adress belongs to one of those subnets the TCP/IP routing will automatically select the correct network card to bind the connection to. If you use an address outside of those subnets the default gateway will be selected.

And according to a Microsoft knowledgebase article it is a very bad idea to have more than one default gateway defined in the entire setup. If you do that the default gateway of the default (primary adapter) should be selected automatically but the routing can get really weird sometimes.

If this is not enough for your routing requirements you will have to manipulate the routing tables manually (and no it is no pretty business to do so). Look  at http://support.microsoft.com/kb/140859 for a starting point about routing table manipulations under Windows NT (still applicable to XP) based systems.

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
Message 5 of 6
(3,483 Views)
Thanks for pointing out how the computer choose the network card. It works after it is changed to a dfferent subnet. Thank you all.
0 Kudos
Message 6 of 6
(3,461 Views)