关于博客时快时慢

2014/08/16 posted in  生活
Tags:  #linux

date: 2014-08-16 11:27

自我感觉博客也是很慢的, 用免费的东西就是这样的鸟,没备案嘛〜 域名是转去国外代理再转回国内的!〜!〜!
本博客第五次搬家了,之前的相册等都木有鸟,有快速备案或更好空间介绍可以联系本博主。。
最近在研究Swoole,,php fans可以一起研究一下。
Swoole:
PHP语言的高性能网络通信框架,提供了PHP语言的异步多线程服务器,异步TCP/UDP网络客户端,异步MySQL,数据库连接池,AsyncTask,消息队列,毫秒定时器,异步文件读写,异步DNS查询。
Swoole可以广泛应用于互联网、移动通信、企业软件、网络游戏、物联网、车联网、智能家庭等领域。 使用PHP+Swoole作为网络通信框架,可以使企业IT研发团队的效率大大提升,更加专注于开发创新产品。

\(serv = new swoole_server("127.0.0.1", 9501);
\)serv->set(array(
'worker_num' => 8, //工作进程数量
'daemonize' => true, //是否作为守护进程
));
\(serv->on('connect', function (\)serv, \(fd){
echo "Client:Connect.\n";
});
\)serv->on('receive', function (\(serv, \)fd, \(from_id, \)data) {
\(serv->send(\)fd, 'Swoole: '.\(data);
\)serv->close(\(fd);
});
\)serv->on('close', function (\(serv, \)fd) {
echo "Client: Close.\n";
});
$serv->start();

\(client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
//设置事件回调函数
\)client->on("connect", function(\(cli) {
\)cli->send("hello world\n");
});
\(client->on("receive", function(\)cli, \(data){
echo "Received: ".\)data."\n";
});
\(client->on("error", function(\)cli){
echo "Connect failed\n";
});
\(client->on("close", function(\)cli){
echo "Connection close\n";
});
//发起网络连接
$client->connect('127.0.0.1', 9501, 0.5);

\(fp = stream_socket_client("tcp://127.0.0.1:80", \)code, \(msg, 3);
if (!\)fp) {
exit("\(errstr (\)errno)\n");
}
\(http_request = "GET /index.html HTTP/1.1\r\n";
\)http_request .= "Host: localhost\r\n\r\n";
fwrite(\(fp, \)http_request);
swoole_event_add(\(fp, function(\)fp){
echo fread(\(fp, 8192);
swoole_event_del(\)fp);
fclose($fp);
});
echo "http response:\n";
//swoole_event_wait(); //低于PHP5.4需要加swoole_event_wait

\(serv = new swoole_server("127.0.0.1", 9502);
\)serv->set(array('task_worker_num' => 4));
\(serv->on('Receive', function(\)serv, \(fd, \)from_id, \(data) {
\)task_id = \(serv->task("Async");
echo "Dispath AsyncTask: id=\)task_id\n";
});
\(serv->on('Task', function (\)serv, \(task_id, \)from_id, \(data) {
echo "New AsyncTask[id=\)task_id]".PHP_EOL;
\(serv->finish("\)data -> OK");
});
\(serv->on('Finish', function (\)serv, \(task_id, \)data) {
echo "AsyncTask[\(task_id] Finish: \)data".PHP_EOL;
});
$serv->start();