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