Networking Forums

Networking Forums > Computer Networking > Linux Networking > socket programming using either eth0 or eth1

Reply
Thread Tools Display Modes

socket programming using either eth0 or eth1

 
 
David Peters
Guest
Posts: n/a

 
      11-17-2004, 06:11 PM
Are there any socket programming samples on how to select which ethernet
port (eth0 or eth1) to use for a socket?


 
Reply With Quote
 
 
 
 
Tauno Voipio
Guest
Posts: n/a

 
      11-17-2004, 07:40 PM
David Peters wrote:
> Are there any socket programming samples on how to select which ethernet
> port (eth0 or eth1) to use for a socket?
>


With normal IP traffic, the network interface is selected
based on the routing to the destination.

Do you mean raw sockets?

--

Tauno Voipio
tauno voipio (at) iki fi


 
Reply With Quote
 
David Peters
Guest
Posts: n/a

 
      11-18-2004, 01:41 PM
Yes. I am working on an app that creates a socket, sends some data, then
closes it. The device I am using has eth0 and possibly eth1. If eth1
exists, I want to use it instead of eth0.

"Tauno Voipio" <(E-Mail Removed)> wrote in message
news:HGOmd.621$(E-Mail Removed)...
> David Peters wrote:
> > Are there any socket programming samples on how to select which ethernet
> > port (eth0 or eth1) to use for a socket?
> >

>
> With normal IP traffic, the network interface is selected
> based on the routing to the destination.
>
> Do you mean raw sockets?
>
> --
>
> Tauno Voipio
> tauno voipio (at) iki fi
>
>



 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      11-20-2004, 07:54 PM

"David Peters" <(E-Mail Removed)> wrote in message
news:419ba344$0$528$(E-Mail Removed)...

> Are there any socket programming samples on how to select which ethernet
> port (eth0 or eth1) to use for a socket?


Are we talking TCP or UDP? Or are we talking some other protocol? And
what do you mean by selecting an ethernet port? Do you mean the packet is
actually sent out that interface? Or do you mean that the source IP address
is the address assigned to that interface?

In short, your post gives us no idea at all what you're trying to do.

DS


 
Reply With Quote
 
Mike Jagdis
Guest
Posts: n/a

 
      11-23-2004, 12:33 PM
David Peters wrote:

> Yes. I am working on an app that creates a socket, sends some data, then
> closes it. The device I am using has eth0 and possibly eth1. If eth1
> exists, I want to use it instead of eth0.


If it's an IP socket you can use a setsockopt(SOL_SOCKET,
SO_BINDTODEVICE, ...) (see "man setsockopt" and "man 7 socket").
If it's a packet socket you look up the interface index with
a SIOCGIFINDEX and bind(2) to that.

Mike

--
Mike Jagdis Web: http://www.eris-associates.co.uk
Eris Associates Limited Tel: +44 7780 608 368
Reading, England Fax: +44 118 926 6974
 
Reply With Quote
 
 
 
Reply

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
eth0 and eth1 on same subnet using netmask Martin Klar Linux Networking 3 09-15-2007 02:35 PM
eth0 answering for eth1 ?? hobbzilla Linux Networking 1 07-24-2006 09:47 PM
eth1 and eth0 different networks and not accessible H. S. Linux Networking 9 05-21-2005 01:57 AM
Eth0 and eth1 Captain Beefheart Linux Networking 7 07-22-2004 06:39 PM
Order eth0, eth1, ... Visvanath Ratnaweera Linux Networking 4 11-13-2003 08:00 PM



1 2 3 4 5 6 7 8 9 10 11