ext-uv/examples/request.php
2012-05-29 08:00:17 +09:00

25 lines
504 B
PHP

<?php
$tcp = uv_tcp_init();
$address = uv_ip4_addr("173.194.38.65","80");
uv_tcp_connect($tcp, $address, function($stat, $client){
$request = <<<EOF
GET / HTTP/1.0
Host: google.com
EOF;
uv_write($client,$request,function($stat, $client){
if ($stat == 0) {
uv_read_start($client,function($buffer, $client){
var_dump($buffer);
uv_close($client);
});
} else {
uv_close($client);
}
});
});
uv_run();