Selects eth device to send/receive

Discussion in 'C Programming' started by SungHyun Nam, Aug 20, 2007.

  1. SungHyun Nam

    SungHyun Nam Guest

    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
     
    SungHyun Nam, Aug 20, 2007
    #1
    1. Advertising

  2. SungHyun Nam

    Ian Collins Guest

    SungHyun Nam wrote:
    > 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.

    --
    Ian Collins.
     
    Ian Collins, Aug 20, 2007
    #2
    1. Advertising

  3. Ian Collins wrote:

    > SungHyun Nam wrote:
    >> 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.
    >

    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.
     
    Ivan Gotovchits, Aug 20, 2007
    #3
  4. In article <fab0uo$m50$>,
    SungHyun Nam <> wrote:

    >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.
    --
    There are some ideas so wrong that only a very intelligent person
    could believe in them. -- George Orwell
     
    Walter Roberson, Aug 20, 2007
    #4
  5. In article <fab6nm$1qn$>,
    Ivan Gotovchits <, > wrote:
    >Ian Collins wrote:


    >> SungHyun Nam wrote:


    >>> 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.


    >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.)
    --
    Is there any thing whereof it may be said, See, this is new? It hath
    been already of old time, which was before us. -- Ecclesiastes
     
    Walter Roberson, Aug 20, 2007
    #5
  6. Walter Roberson wrote:

    > In article <fab6nm$1qn$>,
    > Ivan Gotovchits <, > wrote:
    >>Ian Collins wrote:

    >
    >>> SungHyun Nam wrote:

    >
    >>>> 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.

    >
    >>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.)

    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.
     
    Ivan Gotovchits, Aug 20, 2007
    #6
  7. SungHyun Nam

    CBFalconer Guest

    Ivan Gotovchits wrote:
    > Ian Collins wrote:
    >> SungHyun Nam wrote:
    >>>
    >>> 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.

    >
    > 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.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>



    --
    Posted via a free Usenet account from http://www.teranews.com
     
    CBFalconer, Aug 20, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nishadixit
    Replies:
    5
    Views:
    1,298
    Joe Discar
    Jun 1, 2005
  2. Replies:
    5
    Views:
    41,303
    Roedy Green
    Dec 7, 2005
  3. billie
    Replies:
    3
    Views:
    410
    Tim Golden
    Jan 19, 2006
  4. Replies:
    1
    Views:
    460
    santosh
    Nov 27, 2006
  5. Matt
    Replies:
    0
    Views:
    505
Loading...

Share This Page