Subject: Re: BSD sockets questions
To: Ignatios Souvatzis <is@beverly.kleinbus.org>
From: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>
List: tech-net
Date: 07/12/2000 13:23:46
On Tue, Jul 11, 2000 at 08:05:20PM +0200, Ignatios Souvatzis wrote:
> On Tue, Jul 11, 2000 at 12:19:52PM -0400, der Mouse wrote:
> > > I have 2 questions related to BSD sockets programming:
> > 
> > > 1.How can I explicitly specify outgoing interface when sending packet
> > > using BSD sockets ?
> > 
> > I don't think you can, though there are two things you can do that may
> > come close.  You can bind() the socket before doing a connect(), to
> > specify the address of your end of the connection; however, unless you
> > do something further, the usual routing mechanisms will still be
> > applied to choose the outgoing interface based on the peer address.
> > You can also turn on the SO_DONTROUTE socket option with setsockopt(),
> > but I suspect that will not work unless the peer is on a
> > directly-connected network.
> > 
> > > 2.How can I send limited broadcast (255.255.255.255) using BSD
> > > sockets ?
> > 
> > It doesn't work to use sendto() with a sockaddr_in holding that in its
> > sin_addr?  (I've never tried it myself.)
> > 
> > > How can I specify outgoing interface for such broadcast ?
> > 
> > Good point.  Thinking about it now, I'm not convinced it's possible,
> > and if it is, it probably goes out all interfaces.  You may have to use
> > bpf rather than a simple socket. :-P
> 
> I vaguely remember I fixed, or at least considered to fix, this, so that it
> should be possible now in the same way as you specify a outogoing interface
> for multicast packets.

Besides, you _should_ consider using the link-local "all IPv4 hosts"
multicast...  after all, using the 255.255.255.255, you only address
the IPv4 hosts, so why make the others receive and discard the messages?

Regards,
	-is

-- 
 * Progress (n.): The process through which Usenet has evolved from
   smart people in front of dumb terminals to dumb people in front of
   smart terminals.  -- obs@burnout.demon.co.uk (obscurity)