xref: /php-uv/tests/600-pipe_bind.phpt (revision e76ac0dc)
1--TEST--
2Check for pipe bind
3--FILE--
4<?php
5define("PIPE_PATH", dirname(__FILE__) . "/pipe_test.sock");
6@unlink(PIPE_PATH);
7$a = uv_pipe_init(uv_default_loop(), 0);
8$ret = uv_pipe_bind($a, PIPE_PATH);
9
10uv_listen($a, 8192, function($stream) {
11    $pipe = uv_pipe_init(uv_default_loop(), 0);
12    uv_accept($stream, $pipe);
13    uv_read_start($pipe,function($pipe, $data) use ($stream) {
14        if ($data === \UV::EOF) {
15            return;
16        }
17
18        echo $data;
19        uv_read_stop($pipe);
20        uv_close($stream, function() {
21            @unlink(PIPE_PATH);
22        });
23    });
24});
25
26$pipe = uv_pipe_init(uv_default_loop(), 0);
27uv_pipe_connect($pipe, PIPE_PATH, function($pipe, $status) {
28    uv_write($pipe, "Hello", function($stream, $stat) {
29        uv_close($stream);
30    });
31});
32
33uv_run();
34exit;
35--EXPECT--
36Hello
37