Bind Socket

Bind Socket

Post by Andre Kost » Sun, 18 Feb 2001 03:55:38



In Solaris, how does one bind a socket to a particular interface on a
Solaris machine with more than one Ethernet interface?  I need to be able
to receive Unicast and Broadcast packets on all of the interfaces, and to
be able to determine _which_ interface it came in on.
 
 
 

Bind Socket

Post by Andre Kost » Sun, 18 Feb 2001 05:27:34





>> In Solaris, how does one bind a socket to a particular interface on a
>> Solaris machine with more than one Ethernet interface?  I need to be
>> able to receive Unicast and Broadcast packets on all of the
>> interfaces, and to be able to determine _which_ interface it came in
>> on.

>- Use the SIOCGIFADDR ioctl to map interfaces to addresses.
>- Bind to INADDR_ANY.
>- Use getsockname() to find out which address an accept()ed
>  socket connected.

>#define SIOCGIFADDR _IOWR('i', 13, struct ifreq)    /* get if address */
>ioctl(sock, SIOCGIFADDR, &ifr);     /* something like this */

>Regards,

>Nick Dronen

Ooops, I should have specified.... UDP packets.  There is no
accept/connect....
Also assume that the source IP is unreliable, so the data returned by
recvfrom is useless.  (I can enumerate the interfaces right now, my problem
is determining which interface actually received a particular UDP
255.255.255.255 broadcast)

 
 
 

1. using bind() to bind socket to device

  I'm interested in binding a socket to a device, and have looked at
the pcap source code. In pcap-linux.c, a generic socket address
stucture is used, and a string containing the name of the device to
use is placed in the data portion.  This address structure is then
used in the call to bind.  This seems odd to me and I haven't figured
out from the sock man page why this would work.  The packet man page
suggests using a sockaddr_ll structure, which contains the hardware
address of the device, in the call to bind.  Any idea why this first
method which seems bizzarre to me, would work?

2. USRobotics Megahertz combo

3. Bind: socket operation on non-socket

4. Problem accessing BIOS - newbie, please help

5. bind: socket operation on non-socket

6. Starup Script for PostgreSQL again!!!

7. binding socket

8. block-major-22

9. Releasing a bound socket

10. How to bind sockets address in Solaris?

11. Binding sockets to some available port

12. binding sockets