Subject: Re: BSD sockets questions
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Ignatios Souvatzis <is@beverly.kleinbus.org>
List: tech-net
Date: 07/11/2000 20:05:20
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.
Regards,
-is