1--TEST-- 2recvmsg(): receive SCM_CREDENTIALS messages 3--SKIPIF-- 4<?php 5if (!extension_loaded('sockets')) { 6die('skip sockets extension not available.'); 7} 8if (strtolower(substr(PHP_OS, 0, 3)) == 'win') { 9die('skip not for Microsoft Windows'); 10} 11if (strtolower(substr(PHP_OS, 0, 3)) == 'aix') { 12die('skip not for AIX'); 13} 14--CLEAN-- 15<?php 16$path = __DIR__ . "/unix_sock"; 17@unlink($path); 18--FILE-- 19<?php 20include __DIR__."/mcast_helpers.php.inc"; 21$path = __DIR__ . "/unix_sock"; 22 23@unlink($path); 24 25echo "creating send socket\n"; 26$sends1 = socket_create(AF_UNIX, SOCK_DGRAM, 0) or die("err"); 27var_dump($sends1); 28socket_set_nonblock($sends1) or die("Could not put in non-blocking mode"); 29 30echo "creating receive socket\n"; 31$s = socket_create(AF_UNIX, SOCK_DGRAM, 0) or die("err"); 32var_dump($s); 33$br = socket_bind($s, $path) or die("err"); 34var_dump($br); 35socket_set_nonblock($s) or die("Could not put in non-blocking mode"); 36 37$r = socket_sendmsg($sends1, [ 38 "name" => [ "path" => $path ], 39 "iov" => ["test ", "thing", "\n"], 40 "control" => [ 41 [ 42 "level" => SOL_SOCKET, 43 "type" => SCM_RIGHTS, 44 "data" => [$sends1, STDIN, STDOUT, STDERR], 45 ] 46 ] 47], 0); 48var_dump($r); 49checktimeout($s, 500); 50 51$data = [ 52 "name" => [], 53 "buffer_size" => 2000, 54 "controllen" => socket_cmsg_space(SOL_SOCKET, SCM_RIGHTS, 4) 55]; 56var_dump($data); 57if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); 58print_r($data); 59--EXPECTF-- 60creating send socket 61resource(%d) of type (Socket) 62creating receive socket 63resource(%d) of type (Socket) 64bool(true) 65int(11) 66array(3) { 67 ["name"]=> 68 array(0) { 69 } 70 ["buffer_size"]=> 71 int(2000) 72 ["controllen"]=> 73 int(%d) 74} 75Array 76( 77 [name] => 78 [control] => Array 79 ( 80 [0] => Array 81 ( 82 [level] => %d 83 [type] => %d 84 [data] => Array 85 ( 86 [0] => Resource id #%d 87 [1] => Resource id #%d 88 [2] => Resource id #%d 89 [3] => Resource id #%d 90 ) 91 92 ) 93 94 ) 95 96 [iov] => Array 97 ( 98 [0] => test thing 99 100 ) 101 102 [flags] => 0 103) 104