1--TEST-- 2mixed socket_getopt( resource $socket , int $level , int $optname ) ; 3--CREDITS-- 4marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br 5--SKIPIF-- 6<?php 7if (!extension_loaded('sockets')) { 8 die('skip sockets extension not available.'); 9} 10?> 11--FILE-- 12<?php 13$domain = AF_INET; 14$level = IPPROTO_IP; 15$s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die("err"); 16 17echo "Setting IP_MULTICAST_TTL\n"; 18$r = socket_set_option($s, $level, IP_MULTICAST_TTL, 9); 19var_dump($r); 20$r = socket_getopt($s, $level, IP_MULTICAST_TTL); 21var_dump($r); 22echo "\n"; 23 24echo "Setting IP_MULTICAST_LOOP\n"; 25$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 0); 26var_dump($r); 27$r = socket_getopt($s, $level, IP_MULTICAST_LOOP); 28var_dump($r); 29$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 1); 30var_dump($r); 31$r = socket_getopt($s, $level, IP_MULTICAST_LOOP); 32var_dump($r); 33echo "\n"; 34 35echo "Setting IP_MULTICAST_IF\n"; 36echo "interface 0:\n"; 37$r = socket_set_option($s, $level, IP_MULTICAST_IF, 0); 38var_dump($r); 39$r = socket_getopt($s, $level, IP_MULTICAST_IF); 40var_dump($r); 41echo "interface 1:\n"; 42$r = socket_set_option($s, $level, IP_MULTICAST_IF, 1); 43var_dump($r); 44$r = socket_getopt($s, $level, IP_MULTICAST_IF); 45var_dump($r); 46echo "\n"; 47?> 48--CLEAN-- 49<?php 50unset($domain); 51unset($level); 52socket_close($s); 53unset($s); 54unset($r"); 55?> 56--EXPECT-- 57Setting IP_MULTICAST_TTL 58bool(true) 59int(9) 60 61Setting IP_MULTICAST_LOOP 62bool(true) 63int(0) 64bool(true) 65int(1) 66 67Setting IP_MULTICAST_IF 68interface 0: 69bool(true) 70int(0) 71interface 1: 72bool(true) 73int(1) 74