6

I am trying to use ifconfig to turn on broadcast on my loopback interface. It currently reads:

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384

As you can see, no broadcast address! :( :( :(

I tried this on OS/X but it did not work and it did not give any error or feedback:

ifconfig lo0 broadcast 127.255.255.255

Any guru would know that?


I have one server that sends one packet. I have two clients running on the same machine as the server. I need them to pick up the packet WITHOUT having to force the server to send it twice.

chrisapotek
  • 585
  • 2
  • 6
  • 17
  • 2
    Why do you think you need one? It doesn't really make sence. The loopback doesn't transmit, much less have anything to broadcast to. – Zoredache Aug 26 '12 at 19:20
  • See my edit in the question. – chrisapotek Aug 26 '12 at 19:22
  • 1
    Well, you've got multicast support; could you solve your problem using multicast instead? – nickgrim Aug 26 '12 at 19:50
  • Multicast will require all my clients to join a group, correct? – chrisapotek Aug 26 '12 at 20:02
  • It seams to me that under those circumstances your server should be sending the packet to the loopback address instead of trying to use the loopback address for something it was never designed for. Don't fix what isn't broken. Fix that which is. – John Gardeniers Aug 26 '12 at 21:50
  • @JohnGardeniers But John, you missed the point. If I send to the loopback address then ONLY ONE CLIENT gets the packet. The second one never sees the packet. :( (Even with SO_BROADCAST set). You MUST send to a broadcast address in order for all clients to get it. – chrisapotek Aug 26 '12 at 22:17
  • 1
    I think this is because of the results of the OP's other question: http://serverfault.com/questions/421373/can-i-test-broadcast-packets-on-a-single-machine – jscott Aug 27 '12 at 01:45
  • 5
    Why the loopback interface though. It seems like you could easily setup a dummy interface with private address space instead. – Zoredache Aug 27 '12 at 06:52
  • @chrisapotek, why do you believe only one process at a time can receive packets addressed to the loopback address, or any other address for that matter. Any number of processes can *listen* on the same port on the same address. – John Gardeniers Aug 27 '12 at 09:45
  • @JohnGardeniers Test it for yourself. At least on my OS/X only ONE client gets the packet. The other one never sees it. They are both bound to the same port through SO_REUSE option. – chrisapotek Aug 27 '12 at 13:10

1 Answers1

7

Use multicast. Each client would need to join the group, but this is a very low overhead task. You'd have the additional benefit of being able to have clients on other machines be able to efficiently receive the message.

Failing this, look into one of the various message bus packages (i.e. mqueue, rabbitmq, etc) that will allow for reliable delivery of programmatic information to various processes without a need to reinvent the wheel.

rnxrx
  • 8,143
  • 3
  • 22
  • 31