Selects eth device to send/receive

S

SungHyun Nam

Hello,

If there are two ethernet device, how I can select a device to send/receive?

Actually I want to do loopback test between twe ethernet device.
Send a UDP packet through eth0 and receives that packet from eth1 device.
And vice versa.

Regards,
namsh
 
I

Ian Collins

SungHyun said:
Hello,

If there are two ethernet device, how I can select a device to send/receive?
Asking on a platform specific group would be a good start.
 
I

Ivan Gotovchits

Ian said:
Asking on a platform specific group would be a good start.
If there're two diferent NICs, then they will have different IP's (if you\re
talking about TCP/IP).
So, when receive you need to specify the NIC address, not the INADDR_ANY,
anf to send you must specify address of the desired NIC.
 
W

Walter Roberson

SungHyun Nam said:
If there are two ethernet device, how I can select a device to send/receive?

Ethernet and network communications are not part of the C language;
they are OS-dependant extensions. The appropriate technique can depend
upon the OS and OS version, and it can further depend upon which
networking libraries you link into the executable.

What you ask to do isn't possible for a user-level program in
some OS's; in particular, some OS's insist on choosing the
output communications device based upon the destination address.

[OT]
In some Unix-like operating systems that allow choice, the mechanism is
to bind() the socket to a source IP associated with the communications
device you wish to emit from. But if you want to find out
whether that will work on -your- OS, you will need to read the
documentation. Which will probably be extremely vague on the matter,
expecting that you have read one of the several excellent networking
textbooks.
 
W

Walter Roberson

Ian Collins wrote:
If there're two diferent NICs, then they will have different IP's (if you\re
talking about TCP/IP).

No, that's merely how it happens on the systems you've encountered.
IP addresses need not be associated with particular NICs -- and
*aren't*, once you get into high-reliability systems which have to
keep going smoothly even when individual NICs fail (or their
network link goes down.)
 
I

Ivan Gotovchits

Walter said:
No, that's merely how it happens on the systems you've encountered.
IP addresses need not be associated with particular NICs -- and
*aren't*, once you get into high-reliability systems which have to
keep going smoothly even when individual NICs fail (or their
network link goes down.)
So, can you specify what stack do you use? Because it is really
stack-dependent question, or even platform dependend if it is not POSIX
stack.
Or you can use multicast or broadcast addresses and send messages containing
some magic numbers defining the NIC that sends it. So you can verify that
all transmissions was ok.
 
C

CBFalconer

Ivan said:
If there're two diferent NICs, then they will have different IP's
(if you\re talking about TCP/IP). So, when receive you need to
specify the NIC address, not the INADDR_ANY, anf to send you must
specify address of the desired NIC.

Please don't even attempt to answer OT queries on c.l.c. The
experts to correct mistakes are not present here. Limit your
response to advice on what newsgroups to ask on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top