PHP code example of nethergamesmc / quiche

1. Go to this page and download the library: Download nethergamesmc/quiche library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nethergamesmc / quiche example snippets



$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();
}


$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();
}