File: socket_abstract_path_sendmsg.phpt

package info (click to toggle)
php8.2 8.2.29-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 209,600 kB
  • sloc: ansic: 736,658; php: 33,046; sh: 11,432; cpp: 7,005; pascal: 4,448; javascript: 3,112; asm: 2,404; yacc: 2,222; xml: 1,784; makefile: 689; awk: 148
file content (39 lines) | stat: -rw-r--r-- 854 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--TEST--
Support for paths in the abstract namespace (bind, sendmsg, recvmsg)
--EXTENSIONS--
sockets
--SKIPIF--
<?php
if (PHP_OS != 'Linux') {
    die('skip For Linux only');
}
?>
--FILE--
<?php
include __DIR__."/mcast_helpers.php.inc";

$path = "\x00/bar_foo";

echo "creating send socket\n";
$sends1 = socket_create(AF_UNIX, SOCK_DGRAM, 0) or die("err");
socket_set_nonblock($sends1) or die("Could not put in non-blocking mode");

echo "creating receive socket\n";
$s = socket_create(AF_UNIX, SOCK_DGRAM, 0) or die("err");
socket_bind($s, $path) or die("err");

$r = socket_sendmsg($sends1, [
    "name" => [ "path" => $path],
    "iov" => ["test ", "thing", "\n"],
], 0);
var_dump($r);
checktimeout($s, 500);

if (!socket_recv($s, $buf, 20, 0)) die("recv");
print_r($buf);
?>
--EXPECT--
creating send socket
creating receive socket
int(11)
test thing