0

I'm trying to create a multicast server in PHP using the following code:

$this->sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($this->sock, IPPROTO_IP, MCAST_JOIN_GROUP, ['group' => '255.1.1.1', 'interface' => "eth0"]);
socket_set_option($this->sock, IPPROTO_IP, IP_MULTICAST_TTL, 2);

but I'm receiving the error:

socket_set_option(): unable to set socket option [22]: Invalid argument

On the line setting MCAST_JOIN_GROUP. I can't seem to find much info related to PHP multicast servers online. Does anyone have experience with this problem?

I'm using PHP 5.5.9 on a ubuntu 14.04.2 VMWare 7.1.2 VM. I have verified that eth0 is the primary network interface on the VM.

Rob
  • 1,865
  • 1
  • 14
  • 26
  • What version of PHP are you using? `MCAST_JOIN_GROUP` was not added until 5.4 – Sammitch Dec 03 '15 at 18:09
  • Gotcha, added. Thanks. Was trying to make the question as succinct and direct as possible, but I realize this is useful info. – Rob Dec 03 '15 at 20:09
  • 2
    I think your problem is your MCcast address selection. See: http://stackoverflow.com/questions/236231/how-do-i-choose-a-multicast-address-for-my-applications-use – Sammitch Dec 03 '15 at 23:46
  • 1
    Awesome!! Thanks so much, if you post an answer I'll accept it. I meant to type 225. My brain was blocking that out the wrong IP address as even being a remote possibility. Chalk it up to PHP's famous, high-quality error reporting. ;) – Rob Dec 04 '15 at 17:54

1 Answers1

0

I think your problem is your MCcast address selection. See: How do I choose a multicast address for my application's use? – Sammitch

I meant to type 225. My brain was blocking that out the wrong IP address as even being a remote possibility. – Rob

Armali
  • 18,255
  • 14
  • 57
  • 171