ext-uv/tests/600-pipe_bind.phpt

33 lines
758 B
Plaintext
Raw Normal View History

2012-07-03 01:01:32 +02:00
--TEST--
Check for pipe bind
--FILE--
<?php
define("PIPE_PATH", dirname(__FILE__) . "/pipe_test.sock");
@unlink(PIPE_PATH);
$a = uv_pipe_init(uv_default_loop(), 0);
2015-01-18 02:58:40 +01:00
$ret = uv_pipe_bind($a, PIPE_PATH);
2012-07-03 01:01:32 +02:00
2015-01-18 02:58:40 +01:00
uv_listen($a, 8192, function($stream) {
$pipe = uv_pipe_init(uv_default_loop(), 0);
uv_accept($stream, $pipe);
uv_read_start($pipe,function($pipe, $nread, $buffer) use ($stream) {
2012-07-03 01:01:32 +02:00
echo $buffer;
uv_read_stop($pipe);
2015-01-18 02:58:40 +01:00
uv_close($stream, function() {
2012-07-03 01:01:32 +02:00
@unlink(PIPE_PATH);
});
});
});
$b = uv_pipe_init(uv_default_loop(), 0);
2015-01-18 02:58:40 +01:00
uv_pipe_connect($b, PIPE_PATH, function($a, $b) {
uv_write($b, "Hello", function($stream, $stat) {
2012-07-03 01:01:32 +02:00
uv_close($stream);
});
});
uv_run();
exit;
--EXPECT--
2015-01-18 02:58:40 +01:00
Hello