ext-uv/tests/400-tcp_bind6.phpt

31 lines
716 B
Plaintext
Raw Permalink Normal View History

2012-07-06 17:20:22 +02:00
--TEST--
Check for tcp bind
--FILE--
<?php
$tcp = uv_tcp_init();
2015-01-18 02:58:40 +01:00
uv_tcp_bind6($tcp, uv_ip6_addr('::1', 0));
uv_listen($tcp,100, function($server) {
2012-07-06 17:20:22 +02:00
$client = uv_tcp_init();
uv_accept($server, $client);
2020-02-15 17:40:10 +01:00
uv_read_start($client, function($socket, $buffer) use ($server) {
2012-07-06 17:20:22 +02:00
echo $buffer . PHP_EOL;
uv_close($socket);
2017-05-08 12:07:22 +02:00
uv_close($server);
2012-07-06 17:20:22 +02:00
});
});
$addrinfo = uv_tcp_getsockname($tcp);
$c = uv_tcp_init();
2020-02-15 17:40:10 +01:00
uv_tcp_connect($c, uv_ip6_addr($addrinfo['address'], $addrinfo['port']), function($client, $stat) {
2012-07-06 17:20:22 +02:00
if ($stat == 0) {
uv_write($client,"Hello",function($socket, $stat){
2015-01-18 02:58:40 +01:00
uv_close($socket, function() { });
2012-07-06 17:20:22 +02:00
});
}
});
uv_run();
--EXPECT--
2015-01-18 02:58:40 +01:00
Hello