Here are a few examples of simple or dummy servers written using nanoserv, all of them can be run from the command line.

Click on the filename to view the highlighted source code.


timer_test.php

<?

require "nanoserv/nanoserv.php";

class 
timer_test extends \Nanoserv\Connection_Handler {

    public 
$cd 10;

    function 
on_Accept() {

        
$this->Write("starting countdown in 5 seconds ... ");

        \
Nanoserv\Core::New_Timer(5, array($this"Countdown"));

    }

    function 
Countdown() {

        
$this->Write($this->cd--." ");
        
        \
Nanoserv\Core::New_Timer(0.5, array($this$this->cd "Countdown" "Disconnect"));

    }

}

\
Nanoserv\Core::New_Listener("tcp://0.0.0.0:999""timer_test")->Activate();
\
Nanoserv\Core::Run();

?>