refuge / rbeacon

LAN discovery and presence in Erlang.
Mozilla Public License 2.0
39 stars 7 forks source link

choose best interface #4

Closed benoitc closed 10 years ago

benoitc commented 10 years ago

Instead on broadcasting on all interfaces, zbeacon need to choose the best interface to use and only broadcast on it:

  1. if source is any (INADDR_ANY) then it choose broadcast to INADDR_BROADCAST ie 255.255.255.255 on port, address == broadcast
  2. from a list of broadcast address, pick one from it.

    for all interfaces:

    • get interfaces that are running
    • ignore loopback
    • test if accept broadcast
    • ignore point to point interfaces
    • ignore bounding slaves

    if source is given and == interface name: return it

    if no source interface: if not found interfaces: use latest address broadcast to AF_INET INADDR_BROADCAST on port else: address = broadcast interface address