xref: /php-uv/tests/400-tcp_bind6.phpt (revision e76ac0dc)
1--TEST--
2Check for tcp bind
3--FILE--
4<?php
5$tcp = uv_tcp_init();
6uv_tcp_bind6($tcp, uv_ip6_addr('::1', 0));
7uv_listen($tcp,100, function($server) {
8    $client = uv_tcp_init();
9    uv_accept($server, $client);
10    uv_read_start($client, function($socket, $buffer) use ($server) {
11        echo $buffer . PHP_EOL;
12        uv_close($socket);
13        uv_close($server);
14    });
15});
16
17$addrinfo = uv_tcp_getsockname($tcp);
18
19$c = uv_tcp_init();
20uv_tcp_connect($c, uv_ip6_addr($addrinfo['address'], $addrinfo['port']), function($client, $stat) {
21    if ($stat == 0) {
22        uv_write($client,"Hello",function($socket, $stat){
23            uv_close($socket, function() { });
24        });
25    }
26});
27
28uv_run();
29--EXPECT--
30Hello
31