Subject: Re: BSD sockets questions
To: der fryta <fryta@crawler.com>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-net
Date: 07/11/2000 12:19:52
> 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

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B