You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
17
vendor/swoole/examples/async/dns_lookup.php
vendored
Executable file
17
vendor/swoole/examples/async/dns_lookup.php
vendored
Executable file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
swoole_async_set(array(
|
||||
//使用纯异步IO
|
||||
'use_async_resolver' => true,
|
||||
'disable_dns_cache' => true,
|
||||
'dns_lookup_random' => true,
|
||||
'dns_server' => '114.114.114.114',
|
||||
));
|
||||
swoole_async_dns_lookup("www.sina.com.cn", function ($host, $ip)
|
||||
{
|
||||
echo "{$host} reslove to {$ip}\n";
|
||||
});
|
||||
|
||||
swoole_async_dns_lookup("www.baidu.com", function ($host, $ip)
|
||||
{
|
||||
echo "{$host} reslove to {$ip}\n";
|
||||
});
|
6
vendor/swoole/examples/async/exec.php
vendored
Executable file
6
vendor/swoole/examples/async/exec.php
vendored
Executable file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$pid = Swoole\Async::exec("ps aux", function ($result, $status) {
|
||||
var_dump(strlen($result), $status);
|
||||
});
|
||||
|
||||
var_dump($pid);
|
19
vendor/swoole/examples/async/read.php
vendored
Executable file
19
vendor/swoole/examples/async/read.php
vendored
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
//ini_set("swoole.aio_mode", 1);
|
||||
swoole_async_read(
|
||||
__DIR__ . '/data.txt',
|
||||
function ($filename, $content)
|
||||
{
|
||||
echo "file: $filename\ncontent-length: " . strlen($content) . "\nContent: $content\n";
|
||||
if (empty($content))
|
||||
{
|
||||
echo "file is end.\n";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
8192
|
||||
);
|
10
vendor/swoole/examples/async/readfile.php
vendored
Executable file
10
vendor/swoole/examples/async/readfile.php
vendored
Executable file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
swoole_async::set(['aio_mode' => SWOOLE_AIO_LINUX]);
|
||||
|
||||
swoole_async_readfile(__DIR__.'/../test.jpg', function($filename, $content){
|
||||
echo "file: $filename\ncontent-length: ".strlen($content)."\nContent:\n";
|
||||
swoole_async_writefile(__DIR__.'/test.copy', $content, function($write_file) {
|
||||
echo "file: $write_file\n";
|
||||
swoole_event_exit();
|
||||
});
|
||||
});
|
12
vendor/swoole/examples/async/write.php
vendored
Executable file
12
vendor/swoole/examples/async/write.php
vendored
Executable file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
function write_callback($file, $writen)
|
||||
{
|
||||
echo "write $file [$writen]\n";
|
||||
//return true: write contine. return false: close the file.
|
||||
return true;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 10; $i++)
|
||||
{
|
||||
swoole_async_write("data.txt", str_repeat('A', 10) . "\n", -1, "write_callback");
|
||||
}
|
5
vendor/swoole/examples/async/writefile.php
vendored
Executable file
5
vendor/swoole/examples/async/writefile.php
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
use Swoole\Async;
|
||||
|
||||
//Async::set(array('aio_mode' => SWOOLE_AIO_LINUX));
|
||||
Async::writeFile(__DIR__.'/data2.txt', str_repeat('C', 1023)."\n", null, FILE_APPEND);
|
Reference in New Issue
Block a user