News:

  • February 05, 2023, 07:43:24 PM

Login with username, password and session length

Author Topic: How to programming for selection the network adapter.  (Read 5009 times)

narongy

  • Newbie
  • *
  • Posts: 2
How to programming for selection the network adapter.
« on: September 13, 2013, 12:56:47 AM »
As you know,We found the problem of Used for multiple ethernet cards(NICs), I try to fix it with setting the ENetAddress variable thus as bewlow.

ENetAddress *pSourceAddress;   /* Used for multiple ethernet cards.  This address is the address of the card to use. */

But it dose not work, So, I have see the "Adapter" menu selection in NetEdit3.
Could you give me the code which define the enthernet adapter like in NetEdit3 function or another solution to fix my problem.

Thank you,

narongy

  • Newbie
  • *
  • Posts: 2
Re: How to programming for selection the network adapter.
« Reply #1 on: September 13, 2013, 08:54:34 AM »
For my question above,I can fix it already.
So,I'l like to shear my solution with you.
Normally , If you write the C++ code for connect multiple Ethernet card(NICs).
You must define any value of Ethernet adapter which your controller connection.
In C++ programming,You can follow with my code thus as below .
----------------------------------------------------------------
/**  Step 2, initialize the transport    */
TP.Transport = HEIT_WINSOCK;
TP.Protocol = Protocol;

//Define ENetAddress before call HEIOpenTransport ,
You must define all parameter of ENetAddress type if it isn't completely then your code will not able connect it


ENetAddress SourceAddress;
SourceAddress.AddressIP.Family=2;
SourceAddress.AddressIP.Port=0x7070;

//Define IP Address of Adapter which you want to connect.
/***  Ex.IP Address is 192.168.1.1

SourceAddress.AddressIP.AddressingType.bAddr.b1=192; 
SourceAddress.AddressIP.AddressingType.bAddr.b2=168;
SourceAddress.AddressIP.AddressingType.bAddr.b3=1;
SourceAddress.AddressIP.AddressingType.bAddr.b4=1;
for(int xx=0;xx<8;xx++)
   SourceAddress.AddressIP.Zero[xx]=0;

//Open transport with your adapter selection.   
HEIOpenTransport(&TP, HEIAPIVERSION, &SourceAddress);

------------------------------------------------------------------------
« Last Edit: September 13, 2013, 09:36:24 AM by narongy »

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5793
  • Yes Pinky, Do-more will control the world!
Re: How to programming for selection the network adapter.
« Reply #2 on: September 13, 2013, 03:41:20 PM »
As you have already concluded, you have to preload the adapter's primary IP address into the structure. When the library opens the socket, it binds to the specified address.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO