Comments (3)
协程写法:
写法例子: HTTP/WebSocket客户端
use Swoole\Coroutine;
use Swoole\Coroutine\Http\Client;
use function Swoole\Coroutine\run;
run(function () {
$client = new Client('127.0.0.1', 9501);
$ret = $client->upgrade('/'); # 最关键点就是这里了。
if ($ret) {
while(true) {
$client->push('hello');
var_dump($client->recv());
Coroutine::sleep(0.1);
}
}
});
这里有不少使用例子:
https://github.com/swoole/swoole-src/tree/master/examples/coroutine/websocket
https://github.com/swoole/swoole-src/tree/master/tests/swoole_http_client_coro/websocket
from swoole-cli.
老版本是异步写法 swoole websocket client https://wiki.swoole.com/wiki/page/p-http_client.html
这个我没有用过。
https://wiki.swoole.com/wiki/history/?id=533
例子:
https://github.com/swoole/swoole-src/blob/4.8.x/examples/websocket/client.php
https://github.com/swoole/swoole-src/blob/4.8.x/tests/include/api/swoole_websocket_server/websocket_client.php
examples/websocket/async_client.php
from swoole-cli.
搜索引擎 搜索信息:
https://www.baidu.com/s?ie=utf-8&wd=WebSocket+%E5%AE%A2%E6%88%B7%E7%AB%AF%20%20site:swoole.com
https://cn.bing.com/search?q=WebSocket+%E5%AE%A2%E6%88%B7%E7%AB%AF%20site:swoole.com
https://www.google.com/search?q=WebSocket+%E5%AE%A2%E6%88%B7%E7%AB%AF%20site:swoole.com
from swoole-cli.
Related Issues (20)
- GD 库 库支持.avif 格式的图片
- ./make.sh config 成功,但 ./make.sh build 报错 HOT 1
- 构建加速:方式
- 项目镜像地址
- Makefile:14198 HOT 4
- 是否不支持macos11 HOT 3
- macos 、linux 构建步骤 HOT 5
- gdb swoole-cli core.xx 提示 (no debugging symbols found) ...done. HOT 3
- 5.1 编译pdo 协程 有适配的方案吗? HOT 7
- 大佬,常用的国标加密库能不能加进去? HOT 4
- main分支 alpine 容器内构建 make openssl 失败 HOT 3
- swoole-cli /sync-source-code.php 代码有问题 HOT 1
- windows 使用 Cygwin 构建 swool-cli 不成功。 HOT 18
- swoole-cli 5.1.1 不支持php-fpm运行了吗? HOT 1
- Cygwin 环境中的这个 swoole-cli 似乎不能够很好的支持 phpstan HOT 1
- swoole-cli 是否对 try catch 捕获的协程异常做了一些调整,使调用栈的错误信息不在控制台打印出来了? HOT 7
- build提示 ext/phar/phar_internal.h:619:1: error: expected identifier or '(' HOT 4
- fpm下安装composer失败 HOT 5
- 配合hyperf使用提示 swoole_signalfd_event_callback HOT 4
- Linux 下构建 oci8、pdo_oci 扩展,遇到的 Oracle Instant Client 库不是 .tar.gz 格式和无 Makefile 文件的问题。 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swoole-cli.