nethergamesmc / quiche
基于 Quiche 的 PHP QUIC 实现
1.1.0
2024-06-26 19:27 UTC
Requires
- php: ^8.2
- ext-ffi: *
- ext-sockets: *
- ircmaxell/ffime: dev-master
Requires (Dev)
- phpstan/phpstan: 1.10.56
- phpunit/phpunit: 10.5.9
This package is auto-updated.
Last update: 2024-09-26 20:04:04 UTC
README
安装
composer require nethergamesmc/quiche
需要启用 FFI 并安装 quiche 库。
使用方法
客户端
<?php $clientSocket = new QuicheClientSocket( new SocketAddress("127.0.0.1", 19132), function(QuicheConnection $connection, QuicheStream $stream) : void{ // gets called when a new stream is opened } ); $clientConfig = $clientSocket->getConfig(); $clientConfig->enableBidirectionalStreams(); $clientSocket->connect(); while(true){ $clientSocket->tick(); }
服务器
<?php $serverSocket = new QuicheServerSocket( [new SocketAddress("127.0.0.1", 19132)], function(QuicheConnection $connection, ?QuicheStream $stream) : void{ // gets called when a new connection is established or a new stream is opened } ); $serverConfig = $serverSocket->getConfig(); $serverConfig->loadPrivKeyFromFile($pathToKey); $serverConfig->loadCertChainFromFile($pathToCert); $serverConfig->enableBidirectionalStreams(); while(true){ $serverSocket->tick(); }