# swoole-wiki **Repository Path**: TestsLing/swoole-wiki ## Basic Information - **Project Name**: swoole-wiki - **Description**: 📖Swoole全量Markdown文档, Swoole-Doc, Swoole-Wiki - **Primary Language**: Shell - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Swoole中文文档 全量MarkDown版本 ## 简介 PHP的异步、并行、高性能网络通信引擎,使用纯C语言编写,提供了[PHP语言的异步多线程服务器](https://wiki.swoole.com/wiki/page/p-server.html),[异步TCP/UDP网络客户端](https://wiki.swoole.com/wiki/page/p-client.html),[异步MySQL](https://wiki.swoole.com/wiki/page/517.html),[异步Redis](https://wiki.swoole.com/wiki/page/p-redis.html),[数据库连接池](https://github.com/swoole/framework/blob/master/tests/async_mysql.php),[AsyncTask](https://wiki.swoole.com/wiki/page/134.html),[消息队列](http://wiki.swoole.com/wiki/page/289.html),[毫秒定时器](https://wiki.swoole.com/wiki/page/244.html),[异步文件读写](https://wiki.swoole.com/wiki/page/183.html),[异步DNS查询](https://wiki.swoole.com/wiki/page/186.html)。 Swoole内置了[Http/WebSocket服务器端](https://wiki.swoole.com/wiki/page/326.html)/[客户端](https://wiki.swoole.com/wiki/page/p-http_client.html)、[Http2.0服务器端](https://wiki.swoole.com/wiki/page/326.html)/[客户端](https://wiki.swoole.com/wiki/page/708.html)。 Swoole底层内置了异步非阻塞、多线程的网络IO服务器。PHP程序员仅需处理事件回调即可,无需关心底层。与`Nginx`/`Tornado`/`Node.js`等全异步的框架不同,Swoole既支持全异步,也支持同步。 除了异步IO的支持之外,Swoole为PHP多进程的模式设计了多个并发数据结构和IPC通信机制,可以大大简化多进程并发编程的工作。其中包括了[并发原子计数器](https://wiki.swoole.com/wiki/page/p-atomic.html),[并发HashTable](https://wiki.swoole.com/wiki/page/p-table.html),[Channel](https://wiki.swoole.com/wiki/page/p-channel.html),[Lock](https://wiki.swoole.com/wiki/page/p-lock.html),[进程间通信IPC](https://wiki.swoole.com/wiki/page/363.html)等丰富的功能特性。 Swoole从2.0版本开始支持了**内置协程**,可以使用完全同步的代码实现异步程序。PHP代码无需额外增加任何关键词,底层自动进行协程调度,实现异步。 **Swoole**可以广泛应用于互联网、移动通信、企业软件、网络游戏、物联网、车联网、智能家庭等领域。 使用`PHP+Swoole`作为网络通信框架,可以使企业IT研发团队的效率大大提升,更加专注于开发创新产品。 Swoole是开源免费的自由软件,授权协议是`Apache2.0`。企业和个人开发者均可免费使用Swoole的代码,并且在Swoole之上所作的修改可用于商业产品,无需开源(注:必须保留原作者的版权声明)。 > `1.8.7`或更高版本已完全兼容`PHP7`
> `2.0.12`版本开始不再支持`PHP5` ## 快速索引 - 入门指引 - Server - Coroutine - Runtime - Timer - Memory - Http\Server - WebSocket\Server - Redis\Server - Process - Process\Pool - Client - Event - 高级 - 其他 ## 全量目录 - ### **1** 入门指引 - #### **1.1** 环境依赖 - #### **1.2** 编译安装 - **`1.2.1`** 编译参数 - **`1.2.2`** 常见错误 - **`1.2.3`** Cygwin - #### **1.3** 快速起步 - **`1.3.1`** 创建TCP服务器 - **`1.3.2`** 创建UDP服务器 - **`1.3.3`** 创建Web服务器 - **`1.3.4`** 创建WebSocket服务器 - **`1.3.5`** 设置定时器 - **`1.3.6`** 执行异步任务 - **`1.3.7`** 创建同步TCP客户端 - **`1.3.8`** 创建异步TCP客户端 - **`1.3.9`** 网络通信协议设计 - **`1.3.10`** 使用异步客户端 - **`1.3.11`** 多进程共享数据 - **`1.3.12`** 使用协程客户端 - **`1.3.13`** 协程:并发 shell_exec - **`1.3.14`** 协程:Go + Chan + Defer - **`1.3.15`** 协程:实现 Go 语言风格的 defer - **`1.3.16`** 协程:实现 sync.WaitGroup 功能 - #### **1.4** 编程须知 - **`1.4.1`** sleep/usleep的影响 - **`1.4.2`** exit/die函数的影响 - **`1.4.3`** while循环的影响 - **`1.4.4`** stat缓存清理 - **`1.4.5`** mt_rand随机数 - **`1.4.6`** 进程隔离 - #### **1.5** 版本更新记录 - **`1.5.1`** 4.3.0 [大版本] - **`1.5.3`** 4.2.12 - **`1.5.4`** 4.2.11 - **`1.5.5`** 4.2.10 - **`1.5.6`** 4.2.9 - **`1.5.7`** 4.2.8 - **`1.5.8`** 4.2.7 - **`1.5.9`** 4.2.0 - **`1.5.10`** 4.1.0 - **`1.5.11`** 4.0.1 - **`1.5.12`** 4.0.0 - #### **1.6** 向下不兼容改动 - #### **1.7** 新特性使用 - **`1.7.1`** 4.3.0 在 Process 中使用协程 - **`1.7.2`** 4.3.0 延时事件机制改进 - **`1.7.3`** 2.1.2 进程池模块的使用 - **`1.7.4`** 1.9.24 调度支持 Stream 模式 - **`1.7.5`** 1.9.24 异步客户端自动解析域名 - **`1.7.6`** 1.9.17 支持异步安全重启特性 - **`1.7.7`** 1.9.14 使用异步客户端超时机制 - **`1.7.8`** 1.8.0 使用内置Http异步客户端 - **`1.7.9`** 1.7.16 使用迭代器遍历Server所有连接 - **`1.7.10`** 1.7.5 在Server中使用swoole_table - **`1.7.11`** 1.7.5 swoole_client支持sendfile接口 - **`1.7.12`** 1.7.4 SSL隧道加密TCP-Server - **`1.7.13`** 1.7.4 task进程中使用毫秒定时器 - **`1.7.14`** 1.7.3 固定包头+包体协议自动分包 - **`1.7.15`** 1.7.3 onTask直接return取代finish函数 - **`1.7.16`** 1.7.2 swoole_process多进程模块的使用 - **`1.7.17`** 1.7.2 task进程使用消息队列 - #### **1.8** 项目路线图 - #### **1.9** php.ini选项 - #### **1.10** 内核参数调整 - #### **1.12** 衍生开源项目 - **`1.12.1`** 框架 - **`1.12.2`** 工具 - **`1.12.3`** 分布式 - **`1.12.4`** 通信协议 - #### **1.13** 用户与案例 - **`1.13.1`** 物联网项目 - **`1.13.2`** 网络游戏 - **`1.13.3`** 腾讯(Tencent) - **`1.13.4`** 百度(Baidu.com) - **`1.13.5`** 阅文集团 - **`1.13.6`** BiliBili(哔哩哔哩) - **`1.13.7`** 车轮互联(chelun.com) - **`1.13.8`** (捞月狗) 游戏社区 - #### **1.14** 提交错误报告 - #### **1.15** 常见问题 - **`1.15.1`** 升级swoole版本的常见问题 - **`1.15.2`** 生成可分发的二进制swoole版本 - **`1.15.3`** 在phpinfo中有在php -m中没有 - **`1.15.4`** Connection refused是怎么回事 - **`1.15.5`** Resource temporarily unavailable [11] - **`1.15.6`** Cannot assign requested address [99] - **`1.15.7`** swoole与node.js相比有哪些优势 - **`1.15.8`** swoole与golang相比有哪些优势 - **`1.15.9`** pcre.h: No such file or directory - **`1.15.10`** undefined symbol: __sync_bool_compare_and_swap_4 - **`1.15.11`** 学习Swoole需要掌握哪些基础知识 - **`1.15.12`** 同步阻塞与异步非阻塞适用场景 - **`1.15.13`** PHP7环境下出现zend_mm_heap corrupted - **`1.15.14`** Swoole 项目起源和名字由来 - **`1.15.15`** '__builtin_saddl_overflow' was not declared in this scope - ### **2** Server - #### **2.1** 函数列表 - **`2.1.1`** Server::__construct - **`2.1.2`** Server->set - **`2.1.3`** Server->on - **`2.1.4`** Server->addListener - **`2.1.5`** Server->addProcess - **`2.1.6`** Server->listen - **`2.1.7`** Server->start - **`2.1.8`** Server->reload - **`2.1.9`** Server->stop - **`2.1.10`** Server->shutdown - **`2.1.11`** Server->tick - **`2.1.12`** Server->after - **`2.1.13`** Server->defer - **`2.1.14`** Server->clearTimer - **`2.1.15`** Server->close - **`2.1.16`** Server->send - **`2.1.17`** Server->sendfile - **`2.1.18`** Server->sendto - **`2.1.19`** Server->sendwait - **`2.1.20`** Server->sendMessage - **`2.1.21`** Server->exist - **`2.1.22`** Server->pause - **`2.1.23`** Server->resume - **`2.1.24`** Server->getClientInfo - **`2.1.25`** Server->getClientList - **`2.1.26`** Server->bind - **`2.1.27`** Server->stats - **`2.1.28`** Server->task - **`2.1.29`** Server->taskwait - **`2.1.30`** Server->taskWaitMulti - **`2.1.31`** Server->taskCo - **`2.1.32`** Server->finish - **`2.1.33`** Server->heartbeat - **`2.1.34`** Server->getLastError - **`2.1.35`** Server->getSocket - **`2.1.36`** Server->protect - **`2.1.37`** Server->confirm - #### **2.2** 属性列表 - **`2.2.1`** Server::$setting - **`2.2.2`** Server::$master_pid - **`2.2.3`** Server::$manager_pid - **`2.2.4`** Server::$worker_id - **`2.2.5`** Server::$worker_pid - **`2.2.6`** Server::$taskworker - **`2.2.7`** Server::$connections - **`2.2.8`** Server::$ports - #### **2.3** 配置选项 - **`2.3.1`** reactor_num - **`2.3.2`** worker_num - **`2.3.3`** max_request - **`2.3.4`** max_conn (max_connection) - **`2.3.5`** task_worker_num - **`2.3.6`** task_ipc_mode - **`2.3.7`** task_max_request - **`2.3.8`** task_tmpdir - **`2.3.9`** dispatch_mode - **`2.3.10`** dispatch_func - **`2.3.11`** message_queue_key - **`2.3.12`** daemonize - **`2.3.13`** backlog - **`2.3.14`** log_file - **`2.3.15`** log_level - **`2.3.16`** heartbeat_check_interval - **`2.3.17`** heartbeat_idle_time - **`2.3.18`** open_eof_check - **`2.3.19`** open_eof_split - **`2.3.20`** package_eof - **`2.3.21`** open_length_check - **`2.3.22`** package_length_type - **`2.3.23`** package_length_func - **`2.3.24`** package_max_length - **`2.3.25`** open_cpu_affinity - **`2.3.26`** cpu_affinity_ignore - **`2.3.27`** open_tcp_nodelay - **`2.3.28`** tcp_defer_accept - **`2.3.29`** ssl_cert_file - **`2.3.30`** ssl_method - **`2.3.31`** ssl_ciphers - **`2.3.32`** user - **`2.3.33`** group - **`2.3.34`** chroot - **`2.3.35`** pid_file - **`2.3.36`** pipe_buffer_size - **`2.3.37`** buffer_output_size - **`2.3.38`** socket_buffer_size - **`2.3.39`** enable_unsafe_event - **`2.3.40`** discard_timeout_request - **`2.3.41`** enable_reuse_port - **`2.3.42`** enable_delay_receive - **`2.3.43`** open_http_protocol - **`2.3.44`** open_http2_protocol - **`2.3.45`** open_websocket_protocol - **`2.3.46`** open_mqtt_protocol - **`2.3.47`** open_websocket_close_frame - **`2.3.48`** reload_async - **`2.3.49`** tcp_fastopen - **`2.3.50`** request_slowlog_file - **`2.3.51`** enable_coroutine - **`2.3.52`** max_coroutine - **`2.3.53`** task_enable_coroutine - #### **2.4** 监听端口 - **`2.4.1`** 可选参数 - **`2.4.2`** 可选回调 - **`2.4.3`** 连接迭代器 - #### **2.5** 预定义常量 - #### **2.6** 事件回调函数 - **`2.6.1`** onStart - **`2.6.2`** onShutdown - **`2.6.3`** onWorkerStart - **`2.6.4`** onWorkerStop - **`2.6.5`** onWorkerExit - **`2.6.6`** onConnect - **`2.6.7`** onReceive - **`2.6.8`** onPacket - **`2.6.9`** onClose - **`2.6.10`** onBufferFull - **`2.6.11`** onBufferEmpty - **`2.6.12`** onTask - **`2.6.13`** onFinish - **`2.6.14`** onPipeMessage - **`2.6.15`** onWorkerError - **`2.6.16`** onManagerStart - **`2.6.17`** onManagerStop - #### **2.7** 高级特性 - **`2.7.1`** 改变Worker进程的用户/组 - **`2.7.2`** 回调函数中的 reactor_id 和 fd - **`2.7.3`** Length_Check 和 EOF_Check 的使用 - **`2.7.4`** Worker与Reactor通信模式 - **`2.7.5`** TCP-Keepalive死连接检测 - **`2.7.6`** TCP服务器心跳维持方案 - **`2.7.7`** 多端口监听的使用 - **`2.7.8`** 捕获Server运行期致命错误 - **`2.7.9`** Server内存管理机制 - **`2.7.10`** Server的两种运行模式介绍 - **`2.7.11`** Server中对象的4层生命周期 - **`2.7.12`** 在worker进程内监听一个Server端口 - **`2.7.13`** 在php-fpm/apache中使用task功能 - #### **2.8** 常见问题 - **`2.8.1`** 为什么不要send完后立即close - **`2.8.2`** 如何在回调函数中访问外部的变量 - **`2.8.3`** 是否可以共用1个redis或mysql连接 - **`2.8.4`** 关于onConnect/onReceive/onClose顺序 - **`2.8.5`** 4种PHP回调函数风格 - **`2.8.6`** 不同的Server程序实例间如何通信 - **`2.8.7`** 错误信息:ERROR (9006) - **`2.8.8`** eventLoop has already been created. unable to create swoole_server - #### **2.9** 压力测试 - **`2.9.1`** 并发10万TCP连接的测试 - **`2.9.2`** PHP7+Swoole/Nginx/Golang性能对比 - **`2.9.3`** 全球Web框架权威性能测试 Techempower Web Framework Benchmarks - ### **3** Coroutine - #### **3.1** Coroutine - **`3.1.1`** Coroutine::getCid - **`3.1.2`** Coroutine::create - **`3.1.3`** Coroutine::yield - **`3.1.4`** Coroutine::resume - **`3.1.5`** Coroutine::defer - **`3.1.6`** Coroutine::fread - **`3.1.7`** Coroutine::fgets - **`3.1.8`** Coroutine::fwrite - **`3.1.9`** Coroutine::sleep - **`3.1.10`** Coroutine::gethostbyname - **`3.1.11`** Coroutine::getaddrinfo - **`3.1.12`** Coroutine::exec - **`3.1.13`** Coroutine::readFile - **`3.1.14`** Coroutine::writeFile - **`3.1.15`** Coroutine::stats - **`3.1.16`** Coroutine::statvfs - **`3.1.17`** Coroutine::getBackTrace - **`3.1.18`** Coroutine::listCoroutines - **`3.1.19`** Coroutine::set - #### **3.2** Coroutine\Channel - **`3.2.1`** Coroutine\Channel->__construct - **`3.2.2`** Coroutine\Channel->push - **`3.2.3`** Coroutine\Channel->pop - **`3.2.4`** Coroutine\Channel->stats - **`3.2.5`** Coroutine\Channel->close - **`3.2.6`** Coroutine\Channel->length - **`3.2.7`** Coroutine\Channel->isEmpty - **`3.2.8`** Coroutine\Channel->isFull - **`3.2.9`** Coroutine\Channel->$capacity - **`3.2.10`** Coroutine\Channel->$errCode - #### **3.3** Coroutine\Client - **`3.3.1`** Coroutine\Client->connect - **`3.3.2`** Coroutine\Client->send - **`3.3.3`** Coroutine\Client->recv - **`3.3.4`** Coroutine\Client->close - **`3.3.5`** Coroutine\Client->peek - #### **3.4** Coroutine\Http\Client - **`3.4.1`** 属性列表 - **`3.4.2`** Coroutine\Http\Client->get - **`3.4.3`** Coroutine\Http\Client->post - **`3.4.4`** Coroutine\Http\Client->upgrade - **`3.4.5`** Coroutine\Http\Client->push - **`3.4.6`** Coroutine\Http\Client->recv - **`3.4.7`** Coroutine\Http\Client->addFile - **`3.4.8`** Coroutine\Http\Client->addData - **`3.4.9`** Coroutine\Http\Client->download - #### **3.5** Coroutine\Http2\Client - **`3.5.1`** Coroutine\Http2\Client->__construct - **`3.5.2`** Coroutine\Http2\Client->set - **`3.5.3`** Coroutine\Http2\Client->connect - **`3.5.4`** Coroutine\Http2\Client->send - **`3.5.5`** Coroutine\Http2\Client->write - **`3.5.6`** Coroutine\Http2\Client->recv - **`3.5.7`** Coroutine\Http2\Client->close - #### **3.6** Coroutine\Redis - **`3.6.1`** Coroutine\Redis::__construct - **`3.6.2`** Coroutine\Redis::setOptions - **`3.6.3`** 属性列表 - **`3.6.4`** 事务模式 - **`3.6.5`** 订阅模式 - #### **3.7** Coroutine\Socket - **`3.7.1`** Coroutine\Socket::__construct - **`3.7.2`** Coroutine\Socket->bind - **`3.7.3`** Coroutine\Socket->listen - **`3.7.4`** Coroutine\Socket->accept - **`3.7.5`** Coroutine\Socket->connect - **`3.7.6`** Coroutine\Socket->send - **`3.7.7`** Coroutine\Socket->recv - **`3.7.8`** Coroutine\Socket->sendto - **`3.7.9`** Coroutine\Socket->recvfrom - **`3.7.10`** Coroutine\Socket->getsockname - **`3.7.11`** Coroutine\Socket->getpeername - **`3.7.12`** Coroutine\Socket->close - #### **3.8** Coroutine\MySQL - **`3.8.1`** 属性列表 - **`3.8.2`** Coroutine\MySQL->connect - **`3.8.3`** Coroutine\MySQL->query - **`3.8.4`** Coroutine\MySQL->prepare - **`3.8.5`** Coroutine\MySQL->escape - **`3.8.6`** Coroutine\MySQL\Statement->execute - **`3.8.7`** Coroutine\MySQL\Statement->fetch - **`3.8.8`** Coroutine\MySQL\Statement->fetchAll - **`3.8.9`** Coroutine\MySQL\Statement->nextResult - #### **3.9** Coroutine\PostgreSQL - **`3.9.1`** Coroutine\PostgreSQL->connect - **`3.9.2`** Coroutine\PostgreSQL->query - **`3.9.3`** Coroutine\PostgreSQL->fetchAll - **`3.9.4`** Coroutine\PostgreSQL->affectedRows - **`3.9.5`** Coroutine\PostgreSQL->numRows - **`3.9.6`** Coroutine\PostgreSQL->fetchObject - **`3.9.7`** Coroutine\PostgreSQL->fetchAssoc - **`3.9.8`** Coroutine\PostgreSQL->fetchArray - **`3.9.9`** Coroutine\PostgreSQL->fetchRow - **`3.9.10`** Coroutine\PostgreSQL->metaData - #### **3.10** Server - #### **3.11** 并发调用 - **`3.11.1`** setDefer 机制 - **`3.11.2`** 子协程+通道 - #### **3.12** 实现原理 - **`3.12.1`** 协程与线程 - **`3.12.2`** 发送数据协程调度 - **`3.12.3`** 协程内存开销 - **`3.12.4`** 4.0 协程实现原理 - **`3.12.5`** 协程客户端超时规则 - **`3.12.6`** 协程执行流程 - #### **3.13** 常见问题 - **`3.13.1`** 运行中出现 Fatal error: Maximum function nesting level of '1000' reached, aborting! - **`3.13.2`** 为什么只能在回调函数中使用协程客户端 - **`3.13.3`** 支持协程的回调方法列表 - **`3.13.4`** 错误信息: XXXX client has already been bound to another coroutine - **`3.13.5`** Swoole4 协程与 PHP 的 Yield/Generator 协程有什么区别 - **`3.13.6`** Swoole4 协程与 Go 协程有哪些区别 - #### **3.14** 编程须知 - **`3.14.1`** 在多个协程间共用同一个协程客户端 - **`3.14.2`** 禁止使用协程 API 的场景(2.x 版本) - **`3.14.3`** 使用类静态变量/全局变量保存上下文 - **`3.14.4`** 退出协程 - **`3.14.5`** 异常处理 - #### **3.15** 扩展组件 - **`3.15.1`** MongoDB - #### **3.16** 编程调试 - ### **4** Runtime - #### **4.1** 文件操作 - #### **4.2** 睡眠函数 - #### **4.3** 开关选项 - #### **4.4** 严格模式 - ### **5** Timer - #### **5.1** swoole_timer_tick - #### **5.2** swoole_timer_after - #### **5.3** swoole_timer_clear - ### **6** Memory - #### **6.1** Lock - **`6.1.1`** swoole_lock->__construct - **`6.1.2`** swoole_lock->lock - **`6.1.3`** swoole_lock->trylock - **`6.1.4`** swoole_lock->unlock - **`6.1.5`** swoole_lock->lock_read - **`6.1.6`** swoole_lock->trylock_read - **`6.1.7`** swoole_lock->lockwait - #### **6.2** Buffer - **`6.2.1`** swoole_buffer->__construct - **`6.2.2`** swoole_buffer->append - **`6.2.3`** swoole_buffer->substr - **`6.2.4`** swoole_buffer->clear - **`6.2.5`** swoole_buffer->expand - **`6.2.6`** swoole_buffer->write - **`6.2.7`** swoole_buffer->read - **`6.2.8`** swoole_buffer->recycle - #### **6.3** Table - **`6.3.1`** Table->__construct - **`6.3.2`** Table->column - **`6.3.3`** Table->create - **`6.3.4`** Table->set - **`6.3.5`** Table->incr - **`6.3.6`** Table->decr - **`6.3.7`** Table->get - **`6.3.8`** Table->exist - **`6.3.9`** Table->count - **`6.3.10`** Table->del - #### **6.4** Atomic - **`6.4.1`** swoole_atomic->__construct - **`6.4.2`** swoole_atomic->add - **`6.4.3`** swoole_atomic->sub - **`6.4.4`** swoole_atomic->get - **`6.4.5`** swoole_atomic->set - **`6.4.6`** swoole_atomic->cmpset - **`6.4.7`** swoole_atomic->wait - **`6.4.8`** swoole_atomic->wakeup - #### **6.5** mmap - **`6.5.1`** swoole_mmap::open - #### **6.6** Channel - **`6.6.1`** Channel->__construct - **`6.6.2`** Channel->push - **`6.6.3`** Channel->pop - **`6.6.4`** Channel->stats - #### **6.7** Serialize - **`6.7.1`** swoole_serialize::pack - **`6.7.2`** swoole_serialize::unpack - ### **7** Http\Server - #### **7.1** Http\Server - **`7.1.1`** Http\Server->on - **`7.1.2`** Http\Server->start - #### **7.2** Http\Request - **`7.2.1`** Http\Request->$header - **`7.2.2`** Http\Request->$server - **`7.2.3`** Http\Request->$get - **`7.2.4`** Http\Request->$post - **`7.2.5`** Http\Request->$cookie - **`7.2.6`** Http\Request->$files - **`7.2.7`** Http\Request->rawContent - **`7.2.8`** Http\Request->getData - #### **7.3** Http\Response - **`7.3.1`** Http\Response->header - **`7.3.2`** Http\Response->cookie - **`7.3.3`** Http\Response->status - **`7.3.4`** Http\Response->gzip - **`7.3.5`** Http\Response->redirect - **`7.3.6`** Http\Response->write - **`7.3.7`** Http\Response->sendfile - **`7.3.8`** Http\Response->end - **`7.3.9`** Http\Response->detach - **`7.3.10`** Http\Response::create - #### **7.4** 配置选项 - **`7.4.1`** upload_tmp_dir - **`7.4.2`** http_parse_post - **`7.4.3`** document_root - **`7.4.4`** http_compression - #### **7.5** 常见问题 - **`7.5.1`** CURL发送POST请求服务器端超时 - **`7.5.2`** 使用Chrome访问服务器会产生2次请求 - **`7.5.3`** GET/POST请求的最大尺寸 - ### **8** WebSocket\Server - #### **8.1** 回调函数 - **`8.1.1`** onHandShake - **`8.1.2`** onOpen - **`8.1.3`** onMessage - #### **8.2** 函数列表 - **`8.2.1`** WebSocket\Server->push - **`8.2.2`** WebSocket\Server->exist - **`8.2.3`** WebSocket\Server::pack - **`8.2.4`** WebSocket\Server::unpack - **`8.2.5`** WebSocket\Server->disconnect - **`8.2.6`** WebSocket\Server->isEstablished - #### **8.3** 预定义常量 - #### **8.4** 常见问题 - #### **8.5** 配置选项 - #### **8.6** WebSocket\Frame - ### **9** Redis\Server - #### **9.1** 方法 - **`9.1.1`** Redis\Server->setHandler - **`9.1.2`** Redis\Server::format - #### **9.2** 常量 - ### **10** Process - #### **10.1** Process::__construct - #### **10.2** Process->start - #### **10.3** Process->name - #### **10.4** Process->exec - #### **10.5** Process->write - #### **10.6** Process->read - #### **10.7** Process->setTimeout - #### **10.8** Process->setBlocking - #### **10.9** Process->useQueue - #### **10.10** Process->statQueue - #### **10.11** Process->freeQueue - #### **10.12** Process->push - #### **10.13** Process->pop - #### **10.14** Process->close - #### **10.15** Process->exit - #### **10.16** Process::kill - #### **10.17** Process::wait - #### **10.18** Process::daemon - #### **10.19** Process::signal - #### **10.20** Process::alarm - #### **10.21** Process::setAffinity - #### **10.22** Process::exportSocket - ### **11** Process\Pool - #### **11.1** Process\Pool::__construct - #### **11.2** Process\Pool->on - #### **11.3** Process\Pool->listen - #### **11.4** Process\Pool->write - #### **11.5** Process\Pool->start - #### **11.6** Process\Pool->getProcess - ### **12** Client - #### **12.1** 方法列表 - **`12.1.1`** swoole_client::__construct - **`12.1.2`** swoole_client->set - **`12.1.3`** swoole_client->on - **`12.1.4`** swoole_client->connect - **`12.1.5`** swoole_client->isConnected - **`12.1.6`** swoole_client->getSocket - **`12.1.7`** swoole_client->getSockName - **`12.1.8`** swoole_client->getPeerName - **`12.1.9`** swoole_client->getPeerCert - **`12.1.10`** swoole_client->send - **`12.1.11`** swoole_client->sendto - **`12.1.12`** swoole_client->sendfile - **`12.1.13`** swoole_client->recv - **`12.1.14`** swoole_client->close - **`12.1.15`** swoole_client->sleep - **`12.1.16`** swoole_client->wakeup - **`12.1.17`** swoole_client->enableSSL - #### **12.2** 回调函数 - **`12.2.1`** onConnect - **`12.2.2`** onError - **`12.2.3`** onReceive - **`12.2.4`** onClose - **`12.2.5`** onBufferFull - **`12.2.6`** onBufferEmpty - #### **12.3** 属性列表 - **`12.3.1`** swoole_client->errCode - **`12.3.2`** swoole_client->sock - **`12.3.3`** swoole_client->reuse - #### **12.4** 并行 - **`12.4.1`** swoole_client_select - **`12.4.2`** TCP客户端异步连接 - **`12.4.3`** SWOOLE_KEEP建立TCP长连接 - #### **12.5** 常量 - #### **12.6** 配置选项 - **`12.6.1`** ssl_verify_peer - **`12.6.2`** ssl_host_name - **`12.6.3`** ssl_cafile - **`12.6.4`** ssl_capath - **`12.6.5`** package_length_func - **`12.6.6`** http_proxy_host - #### **12.7** 常见问题 - ### **13** Event - #### **13.1** swoole_event_add - #### **13.2** swoole_event_set - #### **13.3** swoole_event_isset - #### **13.4** swoole_event_write - #### **13.5** swoole_event_del - #### **13.6** swoole_event_exit - #### **13.7** swoole_event_defer - #### **13.8** swoole_event_cycle - #### **13.9** swoole_event_wait - #### **13.10** swoole_event_dispatch - #### **13.11** 常见问题 - **`13.11.1`** epoll_wait 偶尔会用很长时间 - ### **15** 高级 - #### **15.1** Swoole的实现 - #### **15.2** Reactor线程 - #### **15.3** Manager进程 - #### **15.4** Worker进程 - #### **15.5** Reactor、Worker、TaskWorker的关系 - #### **15.6** Task/Finish特性的用途 - #### **15.7** 在php-fpm或apache中使用swoole - #### **15.8** Swoole异步与同步的选择 - #### **15.9** TCP/UDP压测工具 - #### **15.10** swoole服务器如何做到无人值守100%可用 - #### **15.11** MySQL的连接池、异步、断线重连 - #### **15.12** PHP中哪些函数是同步阻塞的 - #### **15.13** 守护进程程序常用数据结构 - **`15.13.1`** 队列(Queue) - **`15.13.2`** 堆(Heap) - **`15.13.3`** 定长数组(SplFixedArray) - #### **15.14** 使用jemalloc优化swoole内存分配性能 - #### **15.15** C开发者如何使用Swoole - #### **15.16** C++开发者如何使用Swoole - #### **15.17** 使用systemd管理swoole服务 - #### **15.18** 网卡中断设置 - #### **15.19** 将Swoole静态编译内嵌到PHP - #### **15.20** 异步回调程序内存管理 - #### **15.21** 日志等级控制 - #### **15.22** 使用 asan 内存检测 - #### **15.23** Windows编译 - #### **15.24** Swoole协程之旅-前篇 - #### **15.25** Swoole协程之旅-中篇 - #### **15.26** Swoole协程之旅-后篇 - #### **15.27** 协程CPU密集场景调度实现 - ### **16** 其他 - #### **16.1** 函数列表 - **`16.1.1`** swoole_set_process_name - **`16.1.2`** swoole_version - **`16.1.3`** swoole_strerror - **`16.1.4`** swoole_errno - **`16.1.5`** swoole_get_local_ip - **`16.1.6`** swoole_clear_dns_cache - **`16.1.7`** swoole_get_local_mac - **`16.1.8`** swoole_cpu_num - **`16.1.9`** swoole_last_error - #### **16.3** Swoole技术会议 - #### **16.4** 工作组(Working Groups) - #### **16.5** 参与开源项目指引 - #### **16.6** 捐赠Swoole项目 - #### **16.7** 加入Swoole开发组 - #### **16.8** 非协程特性独立扩展 (swoole_async) - #### **16.9** 附录:Linux信号列表 - #### **16.10** 附录:Linux错误码(errno)列表 - #### **16.11** 附录:Swoole错误码列表 - #### **16.12** 附录:TCP连接的状态 - #### **16.13** 附录:tcpdump抓包工具的使用 - #### **16.14** 附录:strace工具的使用 - #### **16.15** 附录:gdb工具的使用 - #### **16.16** 附录:lsof工具的使用 - #### **16.17** 附录:perf工具的使用 - #### **16.18** 附录:编译PHP扩展的相关工具 - #### **16.19** 备用:已移除的历史特性 - **`16.19.1`** swoole_server->handler - **`16.19.2`** task_worker_max - **`16.19.3`** swoole_server->addtimer - **`16.19.4`** swoole_server->deltimer - **`16.19.5`** onTimer - **`16.19.6`** swoole_timer_add - **`16.19.7`** swoole_timer_del - **`16.19.8`** swoole_get_mysqli_sock - **`16.19.9`** swoole_mysql_query - **`16.19.10`** onMasterConnect - **`16.19.11`** onMasterClose - **`16.19.12`** Nginx/Golang/Swoole/Node.js的性能对比 - **`16.19.13`** Coroutine::call_user_func - **`16.19.14`** Coroutine::call_user_func_array - **`16.19.15`** Coroutine\Channel::select - **`16.19.16`** task_async - #### **16.20** 历史:版本更新记录(1.x) - **`16.20.1`** 1.10.3 - **`16.20.2`** 1.10.2 - **`16.20.3`** 1.10.1 - **`16.20.4`** 1.10.0 - **`16.20.5`** 1.9.23 - **`16.20.6`** 1.9.22 - **`16.20.7`** 1.9.19 - **`16.20.8`** 1.9.18 - **`16.20.9`** 1.9.17 - **`16.20.10`** 1.9.16 - **`16.20.11`** 1.9.15 - **`16.20.12`** 1.9.14 - **`16.20.13`** 1.9.12 - **`16.20.14`** 1.9.11 - **`16.20.15`** 1.9.9 - **`16.20.16`** 1.9.7 - **`16.20.17`** 1.9.6 - **`16.20.18`** 1.9.5 - **`16.20.19`** 1.9.4 - **`16.20.20`** 1.9.3 - **`16.20.21`** 1.9.2 - **`16.20.22`** 1.9.1 - **`16.20.23`** 1.9.0 - **`16.20.24`** 1.8.13 - **`16.20.25`** 1.8.12 - **`16.20.26`** 1.8.11 - **`16.20.27`** 1.8.10 - **`16.20.28`** 1.8.9 - **`16.20.29`** 1.8.8 - **`16.20.30`** 1.8.7 - **`16.20.31`** 1.8.6 - **`16.20.32`** 1.8.5 - **`16.20.33`** 1.8.4 - **`16.20.34`** 1.8.3 - **`16.20.35`** 1.8.2 - **`16.20.36`** 1.8.1 - **`16.20.37`** 1.8.0 - **`16.20.38`** 1.7.22 - **`16.20.39`** 1.7.21 - **`16.20.40`** 1.7.20 - **`16.20.41`** 1.7.19 - **`16.20.42`** 1.7.18 - **`16.20.43`** 1.7.17 - **`16.20.44`** 1.7.16 - **`16.20.45`** 1.7.15 - **`16.20.46`** 1.7.14 - **`16.20.47`** 1.7.13 - **`16.20.48`** 1.7.12 - **`16.20.49`** 1.7.11 - **`16.20.50`** 1.7.10 - **`16.20.51`** 1.7.9 - **`16.20.52`** 1.7.8 - **`16.20.53`** 1.7.7 - **`16.20.54`** 1.7.6 - **`16.20.55`** 1.7.5 - **`16.20.56`** v1.5 - **`16.20.57`** v1.6 - **`16.20.58`** v1.7 - #### **16.21** 历史:版本更新记录(2.x) - **`16.21.1`** 2.0.1-Alpha - **`16.21.2`** 2.0.5 - **`16.21.3`** 2.0.9 - **`16.21.4`** 1.9.21 - **`16.21.5`** 2.0.10 - **`16.21.6`** 2.0.11 - **`16.21.7`** 2.0.12 - **`16.21.8`** 2.0.13 - **`16.21.9`** 2.1.1 - **`16.21.10`** 2.1.2 - **`16.21.11`** 2.2.0 - **`16.21.12`** 3.0.0 - #### **16.22** 历史:版本更新记录(4.x) - **`16.22.1`** 4.0.3 - **`16.22.2`** 4.0.2 - **`16.22.3`** 4.0.4 - **`16.22.4`** 4.1.1 - **`16.22.5`** 4.1.2 - **`16.22.6`** 4.2.1 - **`16.22.7`** 4.2.2 - **`16.22.8`** 4.2.3 - **`16.22.9`** 4.2.4 - **`16.22.10`** 4.2.5 - **`16.22.11`** 4.2.6 - **`16.22.12`** 4.2.7 - **`16.22.13`** 4.2.9 - **`16.22.14`** 4.2.8