ext-uv/examples/request.php

25 lines
504 B
PHP
Raw Normal View History

2012-05-28 18:31:18 +02:00
<?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);
2012-05-29 01:00:17 +02:00
uv_close($client);
2012-05-28 18:31:18 +02:00
});
} else {
2012-05-29 01:00:17 +02:00
uv_close($client);
2012-05-28 18:31:18 +02:00
}
});
});
uv_run();