How to choose which ethernet card you use
How to choose which ethernet card you use
How to choose which ethernet card you use
How to choose which ethernet card you use
How to choose which ethernet card you use
How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use
How to choose which ethernet card you use How to choose which ethernet card you use
How to choose which ethernet card you use
Go Back  Xtreme Visual Basic Talk > > > How to choose which ethernet card you use


Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2009, 08:13 PM
Mikeatcentre Mikeatcentre is offline
Newcomer
 
Join Date: Nov 2008
Posts: 2
Default How to choose which ethernet card you use


I have a computer, with two seperate NIC cards. They are connected to two seperate networks. I need to figure out the command to use one, or the other. Usually it seems to pick the first card of the two, if both are connected. Its easy in serial data, you just choose the comm port. But in the ethernet world, I cant seem to figure it out. Ive been usuing winsock for my ethernet commands, but cannot seem to figure out how you select which NIC you use. Any help?

EDIT: Im using VB6
Reply With Quote
  #2  
Old 04-30-2009, 12:08 AM
mkaras's Avatar
mkarasHow to choose which ethernet card you use mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

The Windows Desktop OS under which you run your VB6 programs will normally maintain a single active TCP/IP connection even though there may be more than one physical layer connection. You can change the active connection by driving NETSH from VB6 but this process is far from dynamic and would not be particularly practical in a real application.

- mkaras
Reply With Quote
  #3  
Old 04-30-2009, 08:24 AM
Mikeatcentre Mikeatcentre is offline
Newcomer
 
Join Date: Nov 2008
Posts: 2
Default

Well I am running XP, and this is a program that will only be used on one control computer. (Not something that will be distributed) That I will know the static IP, MAC, anything. I just need to figure out how to use the two NICs independantly. Ive seen a couple of programs with people getting the mac, ip, etc for each on a system. But I need to send/receive from them independantly. I guess worse case, I could bridge the two cards using XP, and then use the winsock control like I have, but Im hoping not to have to do that.
Reply With Quote
  #4  
Old 04-30-2009, 10:16 PM
mkaras's Avatar
mkarasHow to choose which ethernet card you use mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

Your coding challenge will be hugely simplified if you leverage the networking capabilities offered by the operating system. Like I said it is possible to auto drive the NetSh utility to get it to toggle which network port is the active one at a given time.

Simplify. It will also make your eventual solution more reliable too.

- mkaras
Reply With Quote
  #5  
Old 05-03-2009, 12:52 PM
dilettante's Avatar
dilettanteHow to choose which ethernet card you use dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,529
Default

For TCP, if you are the server (you will Listen for inbound connections) you should Bind to the LocalPort and LocalIP and then Listen. If you are the client (will Connect) you should Bind to LocalPort = 0 and LocalIP and then Connect.

LocalIP is an IP address on the desired adapter. Yes one adapter can have multiple IP addresses, but on a client OS (e.g. WinXP) you are normally limited to one.

When a client Connects using LocalPort = 0 (default state) Winsock assigns an ephemeral port number (replacing the 0, normally with a value between 1024 and 4999). A client Bind against 0 does the same thing, but can also specify the IP address (roughly "the adapter") to use.


If you know the LocalIP addresses there should be no need to hack around with the network configuration.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How to choose which ethernet card you use
How to choose which ethernet card you use
How to choose which ethernet card you use How to choose which ethernet card you use
How to choose which ethernet card you use
How to choose which ethernet card you use
How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use How to choose which ethernet card you use
How to choose which ethernet card you use
How to choose which ethernet card you use
 
How to choose which ethernet card you use
How to choose which ethernet card you use
 
-->