1--TEST-- 2recvmsg(): basic test 3--EXTENSIONS-- 4sockets 5--SKIPIF-- 6<?php 7 8 9require 'ipv6_skipif.inc'; 10 11if (!defined('IPPROTO_IPV6')) { 12 die('skip IPv6 not available.'); 13} 14if (!defined('IPV6_RECVPKTINFO')) { 15 die('skip IPV6_RECVPKTINFO not available.'); 16} 17?> 18--FILE-- 19<?php 20include __DIR__."/mcast_helpers.php.inc"; 21$addr = '::1'; 22 23echo "creating send socket\n"; 24$sends1 = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die("err"); 25var_dump($sends1); 26$br = socket_bind($sends1, '::', 7001) or die("err"); 27var_dump($br); 28socket_set_nonblock($sends1) or die("Could not put in non-blocking mode"); 29 30echo "creating receive socket\n"; 31$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die("err"); 32var_dump($s); 33$br = socket_bind($s, '::0', 3001) or die("err"); 34var_dump($br); 35 36socket_set_option($s, IPPROTO_IPV6, IPV6_RECVPKTINFO, 1) or die("err"); 37 38$r = socket_sendto($sends1, $m = "testing packet", strlen($m), 0, $addr, 3001); 39var_dump($r); 40if ($r < 12) die; 41checktimeout($s, 500); 42 43$data = [ 44 "name" => ["family" => AF_INET6, "addr" => "::1"], 45 "buffer_size" => 2000, 46 "controllen" => socket_cmsg_space(IPPROTO_IPV6, IPV6_PKTINFO), 47]; 48if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); 49print_r($data); 50?> 51--EXPECTF-- 52creating send socket 53object(Socket)#%d (0) { 54} 55bool(true) 56creating receive socket 57object(Socket)#%d (0) { 58} 59bool(true) 60int(14) 61Array 62( 63 [name] => Array 64 ( 65 [family] => %d 66 [addr] => ::1 67 [port] => 7001 68 [flowinfo] => 0 69 [scope_id] => 0 70 ) 71 72 [control] => Array 73 ( 74 [0] => Array 75 ( 76 [level] => %d 77 [type] => %d 78 [data] => Array 79 ( 80 [addr] => ::1 81 [ifindex] => %d 82 ) 83 84 ) 85 86 ) 87 88 [iov] => Array 89 ( 90 [0] => testing packet 91 ) 92 93 [flags] => 0 94) 95